Fix: handle HTML entities correctly in usernames
In the "previous posts" links generated by the extension, if the
username contained HTML entities, the entities would appear as is and
wouldn't be rendered to the correct character.
An explanation about why this regression occured can be read at
issue 17.
Fixes: #17
Change-Id: Ic7d345ba9b8d06cc97a7ec3d0ef635ba862c81a3
diff --git a/src/content_scripts/console_inject.js b/src/content_scripts/console_inject.js
index e435b15..df20e79 100644
--- a/src/content_scripts/console_inject.js
+++ b/src/content_scripts/console_inject.js
@@ -51,7 +51,7 @@
var forumId =
location.href.split('/forum/')[1].split('/')[0] || '0';
- var name = escapeUsername(nameElement.innerHTML);
+ var name = escapeUsername(nameElement.textContent);
var query1 = encodeURIComponent(
'(creator:"' + name + '" | replier:"' + name +
'") forum:' + forumId);
diff --git a/src/content_scripts/profile_inject.js b/src/content_scripts/profile_inject.js
index 869d8b6..ca16337 100644
--- a/src/content_scripts/profile_inject.js
+++ b/src/content_scripts/profile_inject.js
@@ -3,7 +3,7 @@
document.querySelector('.user-profile__user-links') === null) {
var nameElement = document.querySelector('.user-profile__user-name');
if (nameElement !== null) {
- var name = escapeUsername(nameElement.innerHTML);
+ var name = escapeUsername(nameElement.textContent);
var filter = 'creator:"' + name + '" | replier:"' + name + '"';
var url = document.location.pathname.split('/profile')[0] +
'/threads?thread_filter=' + encodeURIComponent(filter);