OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 tab.pageAction.setIcon(iconFilename); | 133 tab.pageAction.setIcon(iconFilename); |
134 tab.pageAction.setTitle(ext.i18n.getMessage("name")); | 134 tab.pageAction.setTitle(ext.i18n.getMessage("name")); |
135 | 135 |
136 iconAnimation.registerTab(tab, iconFilename); | 136 iconAnimation.registerTab(tab, iconFilename); |
137 | 137 |
138 if (localStorage.shouldShowIcon == "false") | 138 if (localStorage.shouldShowIcon == "false") |
139 tab.pageAction.hide(); | 139 tab.pageAction.hide(); |
140 else | 140 else |
141 tab.pageAction.show(); | 141 tab.pageAction.show(); |
142 | 142 |
143 if (require("info").platform == "chromium") // TODO: Implement context menus f
or Safari | 143 if (excluded) |
144 // Set context menu status according to whether current tab has whitelisted
domain | 144 ext.contextMenus.removeAll(); |
145 if (excluded) | 145 else |
146 chrome.contextMenus.removeAll(); | 146 showContextMenu(); |
147 else | |
148 showContextMenu(); | |
149 } | 147 } |
150 | 148 |
151 /** | 149 /** |
152 * Old versions for Opera stored patterns.ini in the localStorage object, this | 150 * Old versions for Opera stored patterns.ini in the localStorage object, this |
153 * will import it into FilterStorage properly. | 151 * will import it into FilterStorage properly. |
154 */ | 152 */ |
155 function importOldData() | 153 function importOldData() |
156 { | 154 { |
157 if ("patterns.ini" in localStorage) | 155 if ("patterns.ini" in localStorage) |
158 { | 156 { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 }, false); | 253 }, false); |
256 request.send(null); | 254 request.send(null); |
257 } | 255 } |
258 else | 256 else |
259 notifyUser(); | 257 notifyUser(); |
260 } | 258 } |
261 | 259 |
262 // Set up context menu for user selection of elements to block | 260 // Set up context menu for user selection of elements to block |
263 function showContextMenu() | 261 function showContextMenu() |
264 { | 262 { |
265 chrome.contextMenus.removeAll(function() | 263 ext.contextMenus.removeAll(function() |
266 { | 264 { |
267 if(typeof localStorage["shouldShowBlockElementMenu"] == "string" && localSto
rage["shouldShowBlockElementMenu"] == "true") | 265 if(typeof localStorage["shouldShowBlockElementMenu"] == "string" && localSto
rage["shouldShowBlockElementMenu"] == "true") |
268 { | 266 { |
269 chrome.contextMenus.create({"title": chrome.i18n.getMessage("block_element
"), "contexts": ["image", "video", "audio"], "onclick": function(info, tab) | 267 ext.contextMenus.create(ext.i18n.getMessage("block_element"), ["image", "v
ideo", "audio"], function(srcUrl, tab) |
270 { | 268 { |
271 if(info.srcUrl) | 269 if (srcUrl) |
272 chrome.tabs.sendRequest(tab.id, {reqtype: "clickhide-new-filter", fi
lter: info.srcUrl}); | 270 tab.sendMessage({type: "clickhide-new-filter", filter: srcUrl}); |
273 }}); | 271 }); |
274 } | 272 } |
275 }); | 273 }); |
276 } | 274 } |
277 | 275 |
278 /** | 276 /** |
279 * Opens options tab or focuses an existing one, within the last focused window
. | 277 * Opens options tab or focuses an existing one, within the last focused window
. |
280 * @param {Function} callback function to be called with the | 278 * @param {Function} callback function to be called with the |
281 Tab object of the options tab | 279 Tab object of the options tab |
282 */ | 280 */ |
283 function openOptions(callback) | 281 function openOptions(callback) |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 tab.sendMessage({type: "clickhide-deactivate"}); | 456 tab.sendMessage({type: "clickhide-deactivate"}); |
459 refreshIconAndContextMenu(tab); | 457 refreshIconAndContextMenu(tab); |
460 }); | 458 }); |
461 | 459 |
462 setTimeout(function() | 460 setTimeout(function() |
463 { | 461 { |
464 var notificationToShow = Notification.getNextToShow(); | 462 var notificationToShow = Notification.getNextToShow(); |
465 if (notificationToShow) | 463 if (notificationToShow) |
466 showNotification(notificationToShow); | 464 showNotification(notificationToShow); |
467 }, 3 * 60 * 1000); | 465 }, 3 * 60 * 1000); |
OLD | NEW |