Skip to content
This repository was archived by the owner on Nov 15, 2017. It is now read-only.

Commit 4b919de

Browse files
Unrendered Noscript (because CSP) Workaround
1 parent a93530d commit 4b919de

File tree

2 files changed

+6
-29
lines changed

2 files changed

+6
-29
lines changed

js/async.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,13 @@ function onMessageHandler(request, sender, callback) {
231231
forceReload(request.pageURL);
232232
break;
233233

234-
//=====================[ For Bugged Noscript Workaround ]=====================//
235234
case 'checkScriptBlacklisted':
236235
var requestHostname = uriTools.hostnameFromURI(request.url),
237236
boolScriptBlacklisted = HTTPSB.blacklisted(request.url,
238237
'script',
239238
requestHostname);
240239
response = { scriptBlacklisted : boolScriptBlacklisted };
241240
break;
242-
//============================================================================//
243241

244242
default:
245243
// console.error('HTTP Switchboard > onMessage > unknown request: %o', request);

js/contentscript.js

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@ var localStorageHandler = function(mustRemove) {
1313
}
1414
};
1515

16-
//=======================[ Bugged Noscript Workaround ]=======================//
16+
/*------------[ Unrendered Noscript (because CSP) Workaround ]----------------*/
1717

18-
// If script is whitelisted, fixNoscriptTags() is not called. No need to
19-
// mess with <noscript>
20-
// If script is blacklisted, fixNoscriptTags() replaces the bugged <noscript>
21-
// with a <div>, which can render HTML if needed.
22-
var doNoscriptWorkaround = function() {
18+
var fixNoscriptTags = function() {
2319
var a = document.querySelectorAll('noscript');
2420
var i = a.length;
2521
var realNoscript,
@@ -37,35 +33,18 @@ var doNoscriptWorkaround = function() {
3733

3834
var checkScriptBlacklistedHandler = function(response) {
3935
if( response.scriptBlacklisted ) {
40-
doNoscriptWorkaround();
36+
fixNoscriptTags();
4137
}
4238
}
4339

4440
// Checking to see if script is blacklisted
41+
// Not sure if this is right place to check. I don't know if subframes with
42+
// <noscript> tags will be fixed. Should I call this from loadHandler() where
43+
// the old fixNoscriptTags() was called?
4544
chrome.runtime.sendMessage({ what: 'checkScriptBlacklisted',
4645
url: window.location.href
4746
}, checkScriptBlacklistedHandler );
4847

49-
//============================================================================//
50-
51-
/*----------------------------------------------------------------------------*/
52-
53-
//// This is to take care of
54-
//// https://code.google.com/p/chromium/issues/detail?id=232410
55-
//// We look up noscript tags and force the DOM parser to parse
56-
//// them.
57-
//var fixNoscriptTags = function() {
58-
// var a = document.querySelectorAll('noscript');
59-
// var i = a.length;
60-
// var html;
61-
// while ( i-- ) {
62-
// html = a[i].innerHTML;
63-
// html = html.replace(/&lt;/g, '<');
64-
// html = html.replace(/&gt;/g, '>');
65-
// a[i].innerHTML = html;
66-
// }
67-
//};
68-
6948
/*----------------------------------------------------------------------------*/
7049

7150
var collectExternalResources = function() {

0 commit comments

Comments
 (0)