diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index f8f17eb..5cd7613 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -207,8 +207,10 @@ var collapser = (function() { srcProps[tagName], placeholders[tagName].replace('{{url}}', request.url) ); - target.style.setProperty('border', placeholders.border, 'important'); - target.style.setProperty('background', placeholders.background, 'important'); + if ( tagName !== 'iframe' ) { + target.style.setProperty('border', placeholders.border, 'important'); + target.style.setProperty('background', placeholders.background, 'important'); + } } // Renew map: I believe that even if all properties are deleted, an diff --git a/src/js/messaging.js b/src/js/messaging.js index a07b00e..96944dc 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -441,10 +441,16 @@ var contentScriptLocalStorageHandler = function(tabId, pageURL) { // Evaluate many URLs against the matrix. var evaluateURLs = function(tabId, requests) { + var collapse = µm.userSettings.collapseBlocked; + var response = { + collapse: collapse, + requests: requests + }; + // Create evaluation context var tabContext = µm.tabContextManager.lookup(tabId); if ( tabContext === null ) { - return requests; + return response; } var rootHostname = tabContext.rootHostname; @@ -463,14 +469,34 @@ var evaluateURLs = function(tabId, requests) { ); } - return requests; + if ( collapse ) { + placeholders = null; + return response; + } + + if ( placeholders === null ) { + var bg = vAPI.localStorage.getItem('placeholderBackground'); + placeholders = { + background: bg, + border: vAPI.localStorage.getItem('placeholderBorder'), + iframe: vAPI.localStorage.getItem('placeholderDocument').replace('{{bg}}', encodeURIComponent(bg)), + img: vAPI.localStorage.getItem('placeholderImage') + }; + } + response.placeholders = placeholders; + + return response; }; +/******************************************************************************/ + var tagNameToRequestTypeMap = { 'iframe': 'sub_frame', 'img': 'image' }; +var placeholders = null; + /******************************************************************************/ var onMessage = function(request, sender, callback) { @@ -505,18 +531,7 @@ var onMessage = function(request, sender, callback) { break; case 'evaluateURLs': - response = { - collapse: µm.userSettings.collapseBlocked, - requests: evaluateURLs(tabId, request.requests) - }; - if ( !response.collapse ) { - response.placeholders = { - background: vAPI.localStorage.getItem('placeholderBackground'), - border: vAPI.localStorage.getItem('placeholderBorder'), - iframe: vAPI.localStorage.getItem('placeholderDocument'), - img: vAPI.localStorage.getItem('placeholderImage') - }; - } + response = evaluateURLs(tabId, request.requests); break; case 'getUserAgentReplaceStr': diff --git a/src/js/start.js b/src/js/start.js index fd7cdbd..5e9f4b9 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -84,7 +84,9 @@ var defaultLocalUserSettings = { placeholderDocument: [ 'data:text/html,', encodeURIComponent('
'), '{{url}}', encodeURIComponent('')