diff --git a/js/traffic.js b/js/traffic.js index e7d843f..679e29c 100644 --- a/js/traffic.js +++ b/js/traffic.js @@ -19,7 +19,6 @@ Home: https://github.com/gorhill/httpswitchboard */ -/*jshint multistr: true */ /* global chrome, HTTPSB */ /******************************************************************************/ @@ -33,119 +32,124 @@ HTTPSB.webRequest = (function() { // The `id='httpsb'` is important, it allows HTTPSB to detect whether a // specific data URI originates from itself. -var rootFrameReplacement = " \ - \ - \ - \ -Blocked by HTTPSB \ - \ - \ -
\ -
{{hostname}} blocked by HTTP Switchboard
\ -
\ -hpHosts: {{hostname}}
\ -WOT: {{hostname}} \ -
\ -
\ - \ -"; - -var subFrameReplacement = "\ -\ -\ -\ -Blocked by HTTPSB\ -\ -\ -
{{hostname}}
\ -\ -"; +var rootFrameReplacement = [ + '', + '', + '', + '', + 'Blocked by HTTPSB', + '', + '', + '
', + '
{{hostname}} blocked by HTTP Switchboard
', + '
', + 'hpHosts: {{hostname}}
', + 'WOT: {{hostname}}', + '
', + '
', + '', + '' +].join(''); + +var subFrameReplacement = [ + '', + '', + '', + '', + 'Blocked by HTTPSB', + '', + '', + '
{{hostname}}
', + '', + '' +].join(''); /******************************************************************************/ @@ -236,11 +240,11 @@ var onBeforeRootFrameRequestHandler = function(details) { // allows to later check whether the root frame has been unblocked by the // user, in which case we are able to force a reload using a redirect. var html = rootFrameReplacement; - html = html.replace(/{{fontUrl}}/g, httpsb.fontCSSURL); - html = html.replace(/{{cssURL}}/g, httpsb.noopCSSURL); + html = html.replace('{{fontUrl}}', httpsb.fontCSSURL); + html = html.replace('{{cssURL}}', httpsb.noopCSSURL); html = html.replace(/{{hostname}}/g, encodeURIComponent(requestHostname)); - html = html.replace(/{{originalURL}}/g, encodeURIComponent(requestURL)); - html = html.replace(/{{now}}/g, String(Date.now())); + html = html.replace('{{originalURL}}', encodeURIComponent(requestURL)); + html = html.replace('{{now}}', String(Date.now())); var dataURI = 'data:text/html;base64,' + btoa(html); // quickProfiler.stop(); @@ -323,10 +327,11 @@ var processRequest = function(httpsb, details) { // user, in which case we are able to force a reload using a redirect. if ( requestType === 'sub_frame' ) { var html = subFrameReplacement - .replace(/{{fontUrl}}/g, httpsb.fontCSSURL) + .replace('{{fontUrl}}', httpsb.fontCSSURL) .replace(/{{hostname}}/g, requestHostname) + .replace('{{frameSrc}}', requestURL) .replace(/{{subframeColor}}/g, httpsb.userSettings.subframeColor) - .replace(/{{subframeOpacity}}/g, (httpsb.userSettings.subframeOpacity / 100).toFixed(1)); + .replace('{{subframeOpacity}}', (httpsb.userSettings.subframeOpacity / 100).toFixed(1)); return { 'redirectUrl': 'data:text/html,' + encodeURIComponent(html) }; }