Skip to content

Commit e8cdd9c

Browse files
committed
v0.46.56
- Proudly presenting a long-awaited feature: wildcards and single character matching support: --- Domain Matching: domain.com matches domain.com and www.domain.com --- Wildcard Matching: *.domain.com matches anything.domain.com (but not domain.com (no subdomain)) --- Single Character Matching: ?.abc.com matches a.abc.com, b.abc.com, 2.abc.com, etc. --- Note 1: the * and ? can be placed anywhere and/or combined (e.g. ab?.com, cat*.c?) --- Note 2: if there are any duplicates, the whitelist always takes precedence over the blacklist - the above update should also result in further improved performance - added cloaking support for <picture> elements
1 parent 97905d5 commit e8cdd9c

File tree

7 files changed

+60
-45
lines changed

7 files changed

+60
-45
lines changed

changelog.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
v0.46.56 - Wednesday, May 25, 2016
2+
- Proudly presenting a long-awaited feature: wildcards and single character matching support:
3+
--- Domain Matching: domain.com matches domain.com and www.domain.com
4+
--- Wildcard Matching: *.domain.com matches anything.domain.com (but not domain.com (no subdomain))
5+
--- Single Character Matching: ?.abc.com matches a.abc.com, b.abc.com, 2.abc.com, etc.
6+
--- Note 1: the * and ? can be placed anywhere and/or combined (e.g. ab?.com, cat*.c?)
7+
--- Note 2: if there are any duplicates, the whitelist always takes precedence over the blacklist
8+
- the above update should also result in further improved performance
9+
- added cloaking support for <picture> elements
10+
111
v0.46.55.1 - Friday, May 20, 2016
212
- further significant foundation code optimization, resulting in (probably noticeably) faster and more efficient logic and processing
313

@@ -77,7 +87,7 @@ v0.46.45 - Tuesday, February 9, 2016
7787
- improved compatibility with Engadget (thanks Dan), Google+ (scrolling stuttering), YouTube (thanks Jason), Reddit (if using Reddit Enhancement Suite (Night Mode))
7888

7989
v0.46.44 - Friday, February 5, 2016
80-
- polished cloaking so more sites should be readable</li>
90+
- polished cloaking so more sites should be readable
8191
- improved compatibility with Facebook (main timeline post box and Instagram photos), Reddit (if using Reddit Enhancement Suite), the Gawker sites (e.g. Lifehacker, Gizmodo, etc)
8292

8393
v0.46.43 - Friday, February 5, 2016

js/background.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,8 @@ function enabled(tab, dpcloakindex) {
2323
return 'false';
2424
}
2525
function domainCheck(domain) {
26-
if (whiteList.indexOf(domain) != -1) return '0';
27-
if (blackList.indexOf(domain) != -1) return '1';
28-
if (domain.substr(0,4)=='www.') {
29-
var truncdomain = domain.substr(4);
30-
if (whiteList.indexOf(truncdomain) != -1) return '0';
31-
if (blackList.indexOf(truncdomain) != -1) return '1';
32-
} else {
33-
// temp until regex support is coded
34-
var wwwdomain = 'www.'+domain;
35-
if (whiteList.indexOf(wwwdomain) != -1) return '0';
36-
if (blackList.indexOf(wwwdomain) != -1) return '1';
37-
}
26+
if (whiteList && new RegExp(whiteList).test(domain)) return '0';
27+
if (blackList && new RegExp(blackList).test(domain)) return '1';
3828
return '-1';
3929
}
4030
function extractDomainFromURL(url) {
@@ -50,26 +40,30 @@ function domainHandler(domain,action) {
5040
// Initialize local storage
5141
if (typeof(localStorage['whiteList'])=='undefined') localStorage['whiteList'] = JSON.stringify([]);
5242
if (typeof(localStorage['blackList'])=='undefined') localStorage['blackList'] = JSON.stringify([]);
43+
var tempWhitelist = JSON.parse(localStorage['whiteList']);
44+
var tempBlacklist = JSON.parse(localStorage['blackList']);
5345

5446
// Remove domain from whitelist and blacklist
55-
var pos = whiteList.indexOf(domain);
56-
if (pos>-1) whiteList.splice(pos,1);
57-
pos = blackList.indexOf(domain);
58-
if (pos>-1) blackList.splice(pos,1);
47+
var pos = tempWhitelist.indexOf(domain);
48+
if (pos>-1) tempWhitelist.splice(pos,1);
49+
pos = tempBlacklist.indexOf(domain);
50+
if (pos>-1) tempBlacklist.splice(pos,1);
5951

6052
switch(action) {
6153
case 0: // Whitelist
62-
whiteList.push(domain);
54+
tempWhitelist.push(domain);
6355
break;
6456
case 1: // Blacklist
65-
blackList.push(domain);
57+
tempBlacklist.push(domain);
6658
break;
6759
case 2: // Remove
6860
break;
6961
}
7062

71-
localStorage['whiteList'] = JSON.stringify(whiteList);
72-
localStorage['blackList'] = JSON.stringify(blackList);
63+
localStorage['blackList'] = JSON.stringify(tempBlacklist);
64+
localStorage['whiteList'] = JSON.stringify(tempWhitelist);
65+
blackList = regexify(tempBlacklist);
66+
whiteList = regexify(tempWhitelist);
7367
return false;
7468
}
7569
// ----- Options
@@ -282,6 +276,10 @@ function setDPIcon() {
282276
});
283277
});
284278
}
279+
function regexify(arr) {
280+
if (arr.length == 0) return '';
281+
return '(?:www\\.)?(?:'+arr.join('|').replace(/\./g, '\\.').replace(/\*/g, '\\w+').replace(/\?/g, '.')+')';
282+
}
285283
// ----- Request library to support content script communication
286284
chrome.tabs.onUpdated.addListener(function(tabid, changeinfo, tab) {
287285
if (changeinfo.status == "loading") {
@@ -403,8 +401,8 @@ chrome.pageAction.onClicked.addListener(function(tab) {
403401
// Execute
404402
setDefaultOptions();
405403
// save blacklist and whitelist in global variable for faster lookups
406-
blackList = JSON.parse(localStorage['blackList']);
407-
whiteList = JSON.parse(localStorage['whiteList']);
404+
blackList = regexify(JSON.parse(localStorage['blackList']));
405+
whiteList = regexify(JSON.parse(localStorage['whiteList']));
408406
setDPIcon();
409407
dpContext();
410408
if ((!optionExists("version") || localStorage["version"] != version) && localStorage["showUpdateNotifications"] == 'true') {

js/dp.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ function addCloak(sfw, f, fsize, u, bg, text, table, link, bold, o1, o2, collaps
4141
else magic += 'none !important; }';
4242

4343
if (sfw == 'SFW' || sfw == 'SFW1' || sfw == 'SFW2') {
44-
if (o1 == 0 && collapseimage == 'true') magic += ' iframe, img, input[type=image], path, polygon { display: none !important; }';
45-
else magic += ' iframe, img, input[type=image], path, polygon { opacity: '+o1+' !important; } iframe:hover, img:hover, input[type=image]:hover, path:hover, polygon:hover { opacity: '+o2+' !important; }';
44+
if (o1 == 0 && collapseimage == 'true') magic += ' iframe, img, input[type=image], path, polygon, picture { display: none !important; }';
45+
else magic += ' iframe, img, input[type=image], path, polygon, picture { opacity: '+o1+' !important; } iframe:hover, img:hover, input[type=image]:hover, path:hover, polygon:hover { opacity: '+o2+' !important; }';
4646
}
4747
if (sfw == 'SFW') {
4848
if (o1 == 0 && collapseimage == 'true') magic += ' object, embed, param, video, audio { display: none !important; }';
4949
else magic += ' object, embed, param, video, audio { opacity: '+o1+' !important; } object:hover, embed:hover, param:hover, video:hover, audio:hover { opacity: '+o2+' !important; }';
5050
}
5151
if (sfw == 'SFW1') magic += ' object, embed, param, video, audio { display: none !important; opacity: 0 !important; }';
52-
if (sfw == 'Paranoid') magic += ' iframe, img, input[type=image], path, polygon, object, embed, param, video, audio { display: none !important; opacity: 0 !important; }';
52+
if (sfw == 'Paranoid') magic += ' iframe, img, input[type=image], path, polygon, object, embed, param, video, audio, picture { display: none !important; opacity: 0 !important; }';
5353

5454
magic += ' .dp'+timestamp+'_visible { visibility: visible !important; opacity: 1 !important; }';
5555
magic += ' .dp'+timestamp+'_unbold { font-weight: normal !important }';

js/options.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,10 @@ function stylePreset(s) {
471471
// <!-- modified from KB SSL Enforcer: https://code.google.com/p/kbsslenforcer/
472472
function addList(type) {
473473
var domain = $('#url').val();
474-
var domainValidator = new RegExp('^[\\-\\w]+(\\.[\\-\\w]+)*(:[0-9]+)?$'); // https://stackoverflow.com/posts/18696953/revisions
474+
var domainValidator = new RegExp('^[\\-\\w\\*\\?]+(\\.[\\-\\w\\*\\?]+)*(:[0-9]+)?$'); // https://stackoverflow.com/posts/18696953/revisions
475+
domain = domain.toLowerCase();
475476

476-
if (!(domainValidator.test(domain.toLowerCase()))) {
477+
if (!(domainValidator.test(domain))) {
477478
$('#listMsg').html(chrome.i18n.getMessage("invaliddomain")).stop().fadeIn("slow").delay(2000).fadeOut("slow");
478479
} else {
479480
bkg.domainHandler(domain, type);

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
},
2828
"permissions": [ "http://*/*", "https://*/*", "contextMenus", "tabs" ],
2929
"update_url": "http://clients2.google.com/service/update2/crx",
30-
"version": "0.46.55.1"
30+
"version": "0.46.56"
3131
}

options.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,12 @@ <h1>Page Title</h1>
218218
<tr>
219219
<td colspan="2">
220220
<table border="0" cellspacing="0" cellpadding="0">
221-
<tr class="first"><td colspan="2"><label for="url" class="i18_domain">Domain</label>: <input id="url" value="" class="mousetrap" /> <input type="button" value="+ Whitelist" class="i18_addwhitelist" /><input type="button" value="+ Blacklist" class="i18_addblacklist" /><span id="listMsg"></span></td></tr>
221+
<tr class="first"><td colspan="2"><label for="url" class="i18_domain">Domain</label>: <input id="url" value="" class="mousetrap" /> <input type="button" value="+ Whitelist" class="i18_addwhitelist" /><input type="button" value="+ Blacklist" class="i18_addblacklist" /><ul>
222+
<li><small>Domain Matching: <strong>domain.com</strong> matches domain.com and www.domain.com</small></li>
223+
<li><small>Wildcard Matching: <strong>*.domain.com</strong> matches anything.domain.com (but <u>not</u> domain.com (no subdomain))</small></li>
224+
<li><small>Single Character Matching: <strong>?.abc.com</strong> matches a.abc.com, b.abc.com, 2.abc.com, etc.</small></li>
225+
<li><small><strong>Note:</strong> the * and ? can be placed anywhere and/or combined (e.g. ab?.com, cat*.c?)</small></li>
226+
</ul><span id="listMsg"></span></td></tr>
222227
<tr><td><strong class="i18_whitelist">Whitelist</strong> (<a href="javascript:;" class="i18_clear">clear</a>)<div class="list" id="whitelist"></div></td><td><strong class="i18_blacklist">Blacklist</strong> (<a href="javascript:;" class="i18_clear">clear</a>)<div class="list" id="blacklist"></div></td></tr>
223228
</table>
224229
</td>
@@ -235,7 +240,7 @@ <h1>Page Title</h1>
235240
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHiAYJKoZIhvcNAQc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APBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tAgEAMAkGBSsOAwIaBQCgXTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xMTA1MjExNjM4MzBaMCMGCSqGSIb3DQEJBDEWBBRtvTUsMt9WPz42S0PIt3tWVZgkPzANBgkqhkiG9w0BAQEFAASBgKjzksgHn7HfD2z8ZmgLpFnQliQrE4Nevc6d+/vXSATCp+yFH5wElZEiTlj5FAmWqwjj3b67pHPj/5EXlYxHlASMcqasc38WX+S60VFCYIqHbOkgmpb0KnvczFRbQpCBrt+Xo/iKXwMlBU796NqeJP6JHq1FlzOsdbeU98vZ80VF-----END PKCS7-----">
236241
<input type="image" src="./img/icon48.png" border="0" name="submit" class="i18_supportimg" alt="Support Andrew!" title="Support Andrew!">
237242
</form> <span class="i18_support">Support Andrew!</span><br /><br />
238-
<i style="width:937px; display:block;"><span class="i18_people">People who bought Andrew coffee</span>: Leonardo C., 朱之灏, Donald D., John B., Patrick H., Luke C., Eric G., Brian B., Daniel C., Joel D., Joseph W., David M., Rafal W., Ip L., Caillin P., Simon B., Keith T., Peter C., Gordon M., James M., Ranjan S., Philipp B., Rommel G., Todd A., Jason T., Vineet W., Adam C., Jim M., Alex U., Stanislav S., George T., Genere S., Kevin S., Jérémy P., Carlos S., Miguel L., Adrian H., Scott B., Daniel C., Mark M., Timothy D., Alexis B., Peter C., Christiaan E., Matthew L., Russell H., David D., Keith S., Elena G., Rafael V., Scott F., Paul M., Danielle F., 曾 信夫, Jon T., Barry D., Andrew H., Ma X., Frank E., Alex W., Roger S., Artem S., Wassim N., Rajat N., Vadim P., Celia D., Mikyas W., Reann M., Gabriel J., Anthony Z., Kai Cheong W., Jason T., Michael L., Maximilian B., Anton C., Koen de W., Juan de Dios Egido A., Harry P., Jaiganesh R.</i><br />
243+
<i style="width:937px; display:block;"><span class="i18_people">People who bought Andrew coffee</span>: Leonardo C., 朱之灏, Donald D., John B., Patrick H., Luke C., Eric G., Brian B., Daniel C., Joel D., Joseph W., David M., Rafal W., Ip L., Caillin P., Simon B., Keith T., Peter C., Gordon M., James M., Ranjan S., Philipp B., Rommel G., Todd A., Jason T., Vineet W., Adam C., Jim M., Alex U., Stanislav S., George T., Genere S., Kevin S., Jérémy P., Carlos S., Miguel L., Adrian H., Scott B., Daniel C., Mark M., Timothy D., Alexis B., Peter C., Christiaan E., Matthew L., Russell H., David D., Keith S., Elena G., Rafael V., Scott F., Paul M., Danielle F., 曾 信夫, Jon T., Barry D., Andrew H., Ma X., Frank E., Alex W., Roger S., Artem S., Wassim N., Rajat N., Vadim P., Celia D., Mikyas W., Reann M., Gabriel J., Anthony Z., Kai Cheong W., Jason T., Michael L., Maximilian B., Anton C., Koen de W., Juan de Dios Egido A., Harry P., Jaiganesh R., Mark Rafael R., Adam B.</i><br />
239244
<i style="width:937px; display:block;"><span class="i18_translators">People who helped translate</span>: Christoph (Deutsch), Luciano (Español), Yamaji (Japanese), Jérémy (Français), VeryFriend (Russian), Lorenzo (Italian)</i><br />
240245
<i><span class="i18_help">If you can help translate or improve, please contact me</span>: <a href="mailto:[email protected]">[email protected]</a></i><br /><br />
241246
<i><a href="https://twitter.com/andryou" target="_blank">Follow me (@andryou) on Twitter!</a><br /><br />

0 commit comments

Comments
 (0)