From d32137ced04aff9cab03cac4bc5041cfa77f1a7a Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 3 May 2015 07:33:24 -0400 Subject: [PATCH] code review --- src/js/contentscript-end.js | 17 ++++++++--------- src/js/messaging.js | 1 + src/js/start.js | 3 ++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index 466caa2..f8f17eb 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -184,7 +184,6 @@ var collapser = (function() { } var collapse = response.collapse; var placeholders = response.placeholders; - var background = placeholders.background; var i = requests.length; var request, entry, target, tagName; while ( i-- ) { @@ -201,15 +200,15 @@ var collapser = (function() { target = entry.target; if ( collapse ) { target.style.setProperty('display', 'none', 'important'); - } else { - tagName = target.localName; - target.setAttribute( - srcProps[tagName], - placeholders[tagName].replace('{{url}}', request.url) - ); - target.style.setProperty('border', '1px solid rgba(0,0,0,0.05)', 'important'); - target.style.setProperty('background', background, 'important'); + continue; } + tagName = target.localName; + target.setAttribute( + srcProps[tagName], + placeholders[tagName].replace('{{url}}', request.url) + ); + 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 79bfffe..a07b00e 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -512,6 +512,7 @@ var onMessage = function(request, sender, callback) { 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') }; diff --git a/src/js/start.js b/src/js/start.js index f5e79b2..fd7cdbd 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -80,10 +80,11 @@ var defaultLocalUserSettings = { 'rgba(0,0,0,0.02)', ') center center / 10px 10px repeat scroll' ].join(''), + placeholderBorder: '1px solid rgba(0, 0, 0, 0.05)', placeholderDocument: [ 'data:text/html,', encodeURIComponent(''), '{{url}}', encodeURIComponent('')