From b849b8d461479cf6530c77b97b094807840ce0d7 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 12 Oct 2022 19:11:20 +1100 Subject: adding force display noscript. --- content/noscript.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 content/noscript.js (limited to 'content/noscript.js') 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 +* +* 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 . +*/ +"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); + } + } + }); +} -- cgit v1.2.3