Browse Source

this fixes #232 + AMO feedback re. using innerHTML

pull/2/head 0.9.1.2
gorhill 10 years ago
parent
commit
ef68842b80
  1. 29
      src/js/contentscript-end.js
  2. 10
      src/js/messaging.js

29
src/js/contentscript-end.js

@ -69,35 +69,6 @@ vAPI.shutdown.add(function() {
/******************************************************************************/ /******************************************************************************/
/******************************************************************************/ /******************************************************************************/
// Unrendered noscript (because CSP) workaround
// Executed once.
(function() {
var checkScriptBlacklistedHandler = function(response) {
if ( !response.scriptBlacklisted ) {
return;
}
var scripts = document.querySelectorAll('noscript');
var i = scripts.length;
var realNoscript, fakeNoscript;
while ( i-- ) {
realNoscript = scripts[i];
fakeNoscript = document.createElement('div');
fakeNoscript.innerHTML = '<!-- uMatrix NOSCRIPT tag replacement: see <https://github.com/gorhill/httpswitchboard/issues/177> -->\n' + realNoscript.textContent;
realNoscript.parentNode.replaceChild(fakeNoscript, realNoscript);
}
};
localMessager.send({
what: 'checkScriptBlacklisted',
url: window.location.href
}, checkScriptBlacklistedHandler);
})();
/******************************************************************************/
/******************************************************************************/
// Executed only once. // Executed only once.
(function() { (function() {

10
src/js/messaging.js

@ -522,16 +522,6 @@ var onMessage = function(request, sender, callback) {
var response; var response;
switch ( request.what ) { switch ( request.what ) {
case 'checkScriptBlacklisted':
response = {
scriptBlacklisted: µm.mustBlock(
µm.scopeFromURL(request.url),
µm.hostnameFromURL(request.url),
'script'
)
};
break;
case 'contentScriptHasLocalStorage': case 'contentScriptHasLocalStorage':
response = contentScriptLocalStorageHandler(tabId, request.url); response = contentScriptLocalStorageHandler(tabId, request.url);
break; break;

Loading…
Cancel
Save