diff options
-rw-r--r-- | src/js/popup.js | 25 | ||||
-rw-r--r-- | src/popup.html | 6 |
2 files changed, 18 insertions, 13 deletions
diff --git a/src/js/popup.js b/src/js/popup.js index ad5e4be..d72ff6a 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -196,27 +196,32 @@ var updateDynamicFilterCell = function(scope, des, type, rule) { } cell.toggleClass('ownRule', ownRule); - if ( scope !== '.' || des === '*' ) { - return; - } - if ( popupData.hostnameDict.hasOwnProperty(des) === false ) { + // IMPORTANT: It is completely assumed the first node is a TEXT_NODE, so + // ensure this in the HTML file counterpart when you make + // changes + var textNode = cell.nodeAt(0).firstChild; + + // Since this may be a cell from a reused row, we need to clear text + // content if we can't compute request counts. + if ( scope !== '.' || des === '*' || popupData.hostnameDict.hasOwnProperty(des) === false ) { + textNode.nodeValue = ' '; return; } + var hnDetails = popupData.hostnameDict[des]; var aCount = hnDetails.allowCount; var bCount = hnDetails.blockCount; if ( aCount === 0 && bCount === 0 ) { + textNode.nodeValue = ' '; return; } + // https://github.com/gorhill/uBlock/issues/471 aCount = Math.min(Math.ceil(Math.log(aCount + 1) / Math.LN10), 3); bCount = Math.min(Math.ceil(Math.log(bCount + 1) / Math.LN10), 3); - // IMPORTANT: It is completely assumed the first node is a TEXT_NODE, so - // ensure this in the HTML file counterpart when you make - // changes - cell.nodeAt(0).firstChild.nodeValue = threePlus.slice(0, aCount) + - sixSpace.slice(aCount + bCount) + - threeMinus.slice(0, bCount); + textNode.nodeValue = threePlus.slice(0, aCount) + + sixSpace.slice(aCount + bCount) + + threeMinus.slice(0, bCount); }; /******************************************************************************/ diff --git a/src/popup.html b/src/popup.html index 07a39d4..d276932 100644 --- a/src/popup.html +++ b/src/popup.html @@ -28,9 +28,9 @@ <div id="refresh" class="fa"></div> </div><!-- DO NOT REMOVE --><div> <div id="dynamicFilteringContainer"> - <div><span data-i18n="popupAnyRulePrompt"></span><span data-src="/" data-des="*" data-type="*"> </span><span data-src="." data-des="*" data-type="*"></span></div> - <div><span data-i18n="popupImageRulePrompt"></span><span data-src="/" data-des="*" data-type="image"> </span><span data-src="." data-des="*" data-type="image"></span></div> - <div><span data-i18n="popup3pAnyRulePrompt"></span><span data-src="/" data-des="*" data-type="3p"> </span><span data-src="." data-des="*" data-type="3p"></span></div> + <div><span data-i18n="popupAnyRulePrompt"></span><span data-src="/" data-des="*" data-type="*"> </span><span data-src="." data-des="*" data-type="*"> </span></div> + <div><span data-i18n="popupImageRulePrompt"></span><span data-src="/" data-des="*" data-type="image"> </span><span data-src="." data-des="*" data-type="image"> </span></div> + <div><span data-i18n="popup3pAnyRulePrompt"></span><span data-src="/" data-des="*" data-type="3p"> </span><span data-src="." data-des="*" data-type="3p"> </span></div> <div><span data-i18n="popupInlineScriptRulePrompt"></span><span data-src="/" data-des="*" data-type="inline-script"> </span><span data-src="." data-des="*" data-type="inline-script"> </span></div> <div><span data-i18n="popup1pScriptRulePrompt"></span><span data-src="/" data-des="*" data-type="1p-script"> </span><span data-src="." data-des="*" data-type="1p-script"> </span></div> <div><span data-i18n="popup3pScriptRulePrompt"></span><span data-src="/" data-des="*" data-type="3p-script"> </span><span data-src="." data-des="*" data-type="3p-script"> </span></div> |