| Index: options.js |
| =================================================================== |
| --- a/options.js |
| +++ b/options.js |
| @@ -646,15 +646,67 @@ |
| ext.backgroundPage.sendMessage( |
| { |
| type: "app.get", |
| - what: "addonVersion" |
| + what: "info" |
| }, |
| - function(addonVersion) |
| + function(info) |
| { |
| - E("abp-version").textContent = addonVersion; |
| - }); |
| - getDocLink("releases", function(link) |
| - { |
| - E("link-version").setAttribute("href", link); |
| + E("abp-version").textContent = info.addonVersion; |
| + |
| + // Don't link version for development builds |
| + if (info.addonVersion.split(".").length > 3) |
| + return; |
| + |
| + E("version").setAttribute("href", "#"); |
| + E("version").addEventListener("click", function(event) |
| + { |
| + event.preventDefault(); |
| + |
| + fetch("https://adblockplus.org/atom/?section=releases&limit=100").then(function(response) |
| + { |
| + return repsonse.ok ? response.text() : ""; |
| + }).then( |
| + function(text) |
| + { |
| + var doc = new DOMParser().parseFromString(text, "application/xml"); |
| + var entries = doc.getElementsByTagName("entry"); |
| + for (var i = 0; i < entries.length; i++) |
| + { |
| + var entry = entries[i]; |
| + var title = entry.getElementsByTagName("title")[0]; |
| + if (!title) |
| + continue; |
| + |
| + var lowerCaseTitleText = title.textContent.toLowerCase(); |
| + if (lowerCaseTitleText.split(/\W+/).indexOf(info.application) == -1) |
| + continue; |
| + if (lowerCaseTitleText.split(/\s+/).indexOf(info.addonVersion) == -1) |
| + continue; |
| + |
| + var links = entry.getElementsByTagName("link"); |
| + for (var j = 0; j < links.length; j++) |
| + { |
| + var link = links[j]; |
| + var href = link.getAttribute("href"); |
| + |
| + if (link.getAttribute("rel") == "alternate" && href) |
| + return href; |
| + } |
| + } |
| + }, |
| + function() |
| + { |
| + return null; |
| + } |
| + ).then(function(url) |
| + { |
| + if (url) |
| + document.location.href = url; |
| + else |
| + getDocLink("releases", function(link) |
| + { |
| + document.location.href = link; |
| + }); |
| + }); |
| }); |
| getDocLink("contribute", function(link) |