Skip to content

Instantly share code, notes, and snippets.

@jridgewell
Created June 1, 2013 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jridgewell/5691773 to your computer and use it in GitHub Desktop.
Save jridgewell/5691773 to your computer and use it in GitHub Desktop.
Patch Safari Adblock to only blacklist sites.
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