Index: lib/ui.js |
=================================================================== |
--- a/lib/ui.js |
+++ b/lib/ui.js |
@@ -895,43 +895,53 @@ |
/** |
* Handles clicks inside the browser's content area, will intercept clicks on |
- * abp: links. This can be called either with an event object or with the link |
- * target (if it is the former then link target will be retrieved from event |
- * target). |
+ * abp: links as well as links to subscribe.adblockplus.org. |
*/ |
- onBrowserClick: function (/**Window*/ window, /**Event*/ event, /**String*/ linkTarget) |
+ onBrowserClick: function (/**Window*/ window, /**Event*/ event) |
Wladimir Palant
2015/07/20 11:23:10
It seems that currently we will always get an even
|
{ |
- if (event) |
+ // Ignore right-clicks |
+ if (event.button == 2) |
+ return; |
+ |
+ // Search the link associated with the click |
+ let link = event.target; |
+ while (!(link instanceof Ci.nsIDOMHTMLAnchorElement)) |
{ |
- // Ignore right-clicks |
- if (event.button == 2) |
+ link = link.parentNode; |
+ |
+ if (!link) |
return; |
- |
- // Search the link associated with the click |
- let link = event.target; |
- while (link && !(link instanceof Ci.nsIDOMHTMLAnchorElement)) |
- link = link.parentNode; |
- |
- if (!link || link.protocol != "abp:") |
- return; |
- |
- // This is our link - make sure the browser doesn't handle it |
- event.preventDefault(); |
- event.stopPropagation(); |
- |
- linkTarget = link.href; |
} |
- let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(linkTarget); |
- if (!match) |
+ let queryString = null; |
+ if (link.protocol == "http:" || link.protocol == "https:") |
+ { |
+ if (link.host == "subscribe.adblockplus.org" || link.pathname == "/") |
Wladimir Palant
2015/07/20 11:23:10
Shouldn't this be && rather than ||?
Thomas Greiner
2015/07/20 14:00:53
Done.
|
+ queryString = link.search.substr(1); |
+ } |
+ else |
+ { |
+ // Firefox doesn't populate the "search" property for links with |
+ // non-standard URL schemes so we need to extract the query string |
+ // manually |
+ let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(link.href); |
+ if (match) |
+ queryString = match[1]; |
+ } |
+ |
+ if (!queryString) |
return; |
+ // This is our link - make sure the browser doesn't handle it |
+ event.preventDefault(); |
+ event.stopPropagation(); |
+ |
// Decode URL parameters |
let title = null; |
let url = null; |
let mainSubscriptionTitle = null; |
let mainSubscriptionURL = null; |
- for (let param of match[1].split('&')) |
+ for (let param of queryString.split("&")) |
{ |
let parts = param.split("=", 2); |
if (parts.length != 2 || !/\S/.test(parts[1])) |