aboutsummaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-10-12 19:11:20 +1100
committerYuchen Pei <hi@ypei.me>2022-10-12 19:11:20 +1100
commitb849b8d461479cf6530c77b97b094807840ce0d7 (patch)
treea5b59fbce035d698011d9b55e6e88dae4b1f65d4 /content
parent88fa677b51b6b1eb814866ea08129a6b7cda9ddb (diff)
adding force display noscript.
Diffstat (limited to 'content')
-rw-r--r--content/noscript.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/content/noscript.js b/content/noscript.js
new file mode 100644
index 0000000..9ea2f08
--- /dev/null
+++ b/content/noscript.js
@@ -0,0 +1,38 @@
+/**
+* GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript.
+*
+* Copyright (C) 2022 Yuchen Pei <id@ypei.org>
+*
+* This file is part of GNU LibreJS.
+*
+* GNU LibreJS is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* GNU LibreJS is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>.
+*/
+"use strict";
+{
+ browser.runtime.onMessage.addListener(async m => {
+ if (m.action === 'forceNoscript') {
+ try {
+ debug("Received message", m);
+ for (const noscript of document.querySelectorAll(
+ 'noscript:not([data-librejs-nodisplay])')) {
+ const replacement = document.createElement('span');
+ replacement.innerHTML = noscript.innerHTML;
+ noscript.replaceWith(replacement);
+ }
+ } catch (e) {
+ console.error(e);
+ }
+ }
+ });
+}