Created
June 1, 2013 21:22
-
-
Save jridgewell/5691773 to your computer and use it in GitHub Desktop.
Patch Safari Adblock to only blacklist sites.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/background.js b/background.js | |
index f55a9ac..8e2160a 100644 | |
--- a/background.js | |
+++ b/background.js | |
@@ -295,6 +295,11 @@ | |
try_to_unwhitelist = function(url) { | |
url = url.replace(/#.*$/, ''); // Whitelist ignores anchors | |
var custom_filters = get_custom_filters_text().split('\n'); | |
+ var domain = parseUri(url).hostname.match(/[^.]+\.[^.]+$/); | |
+ custom_filters[0] += "|~" + domain; | |
+ set_custom_filters_text(custom_filters.join('\n')); | |
+ return true; | |
+ | |
for (var i = 0; i < custom_filters.length; i++) { | |
var text = custom_filters[i]; | |
if (!Filter.isWhitelistFilter(text)) | |
diff --git a/safari_bg.js b/safari_bg.js | |
index 6be4b83..2517ed1 100644 | |
--- a/safari_bg.js | |
+++ b/safari_bg.js | |
@@ -60,9 +60,9 @@ safari.application.addEventListener("command", function(event) { | |
} else if (command === "unwhitelist-currentpage") { | |
var tab = browserWindow.activeTab; | |
var unwhitelisted = false; | |
- while (try_to_unwhitelist(tab.url)) { | |
- unwhitelisted = true; | |
- } | |
+ //while (try_to_unwhitelist(tab.url)) { | |
+ unwhitelisted = try_to_unwhitelist(tab.url); | |
+ //} | |
if (unwhitelisted) { | |
tab.url = tab.url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment