| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 "use strict"; | 1 "use strict"; |
| 2 | 2 |
| 3 (function() | 3 (function() |
| 4 { | 4 { |
| 5 var supportedPlatforms = { | 5 var supportedPlatforms = { |
| 6 | 6 |
| 7 // Desktop browsers | 7 // Desktop browsers |
| 8 "chrome": { | 8 "chrome": "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaibdcc ddilifddb", |
| 9 installer: "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaib dccddilifddb", | 9 "opera": "https://addons.opera.com/extensions/details/opera-adblock/?display =en-US", |
| 10 label: "Chrome" | 10 "yandexbrowser": "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpk daibdccddilifddb", |
|
juliandoucette
2018/04/06 12:35:23
Are these labels still being used?
ire
2018/04/06 13:21:49
Good catch, forgot about that! Removed.
| |
| 11 }, | 11 "msie": "https://update.adblockplus.org/latest/adblockplusie.exe", |
| 12 "opera": { | 12 "msedge": "https://www.microsoft.com/store/p/adblock-plus/9nblggh4r9nz", |
| 13 installer: "https://addons.opera.com/extensions/details/opera-adblock/?dis play=en-US", | 13 "firefox": "https://update.adblockplus.org/latest/adblockplusfirefox.xpi", |
| 14 label: "Opera" | 14 "safari": "https://update.adblockplus.org/latest/adblockplussafari.safariext z", |
| 15 }, | |
| 16 "yandexbrowser": { | |
| 17 installer: "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaib dccddilifddb", | |
| 18 label: "Yandex Browser" | |
| 19 }, | |
| 20 "msie": { | |
| 21 installer: "https://update.adblockplus.org/latest/adblockplusie.exe", | |
| 22 label: "Internet Explorer" | |
| 23 }, | |
| 24 "msedge": { | |
| 25 installer: "https://www.microsoft.com/store/p/adblock-plus/9nblggh4r9nz", | |
| 26 label: "Micrsoft Edge" | |
| 27 }, | |
| 28 "firefox": { | |
| 29 installer: "https://update.adblockplus.org/latest/adblockplusfirefox.xpi", | |
| 30 label: "Firefox" | |
| 31 }, | |
| 32 "safari": { | |
| 33 installer: "https://update.adblockplus.org/latest/adblockplussafari.safari extz", | |
| 34 label: "Safari" | |
| 35 }, | |
| 36 "maxthon": "", | 15 "maxthon": "", |
| 37 | 16 |
| 38 // Mobile platforms | 17 // Mobile platforms |
| 39 "ios": { | 18 "ios": "https://eyeo.to/adblockbrowser/ios/abp-website", |
| 40 installer: "https://eyeo.to/adblockbrowser/ios/abp-website", | 19 "android": "https://eyeo.to/adblockbrowser/android/abp-website" |
| 41 label: "iOS", | |
| 42 }, | |
| 43 "android": { | |
| 44 installer: "https://eyeo.to/adblockbrowser/android/abp-website", | |
| 45 label: "Android" | |
| 46 } | |
| 47 }; | 20 }; |
| 48 | 21 |
| 49 function setupHeroDownloadButton() | 22 function setupHeroDownloadButton() |
| 50 { | 23 { |
| 51 var detectedPlatform = Object.keys(supportedPlatforms).find(hasOwnProperty.b ind(bowser)); | 24 var detectedPlatform = Object.keys(supportedPlatforms) |
|
juliandoucette
2018/04/06 12:35:23
NIT: Line is too long?
ire
2018/04/06 13:21:49
Done.
| |
| 25 .find(bowser.hasOwnProperty.bind(bowser)); | |
| 52 | 26 |
| 53 if (!detectedPlatform) return; | 27 if (!detectedPlatform) return; |
| 54 | 28 |
| 55 document.body.classList.add(detectedPlatform); | 29 document.body.classList.add(detectedPlatform); |
| 56 | 30 |
| 57 if (detectedPlatform === "maxthon") return; | 31 if (detectedPlatform == "maxthon") return; |
|
juliandoucette
2018/04/06 12:35:23
NIT: Code style says we should use == :(
ire
2018/04/06 13:21:49
I can't seem to find where it says that?
(Done an
juliandoucette
2018/04/06 16:29:16
It's kindof obscure:
ABP Coding style > General >
ire
2018/04/09 09:24:01
Acknowledged.
| |
| 58 | 32 |
| 59 var heroDownloadButton = document.getElementById("hero-download-button"); | 33 var heroDownloadButton = document.getElementById("hero-download-button"); |
| 60 heroDownloadButton.href = supportedPlatforms[detectedPlatform].installer; | 34 heroDownloadButton.href = supportedPlatforms[detectedPlatform]; |
| 61 heroDownloadButton.innerHTML = document | 35 heroDownloadButton.textContent = document |
| 62 .getElementById("hero-download-button-template") | 36 .getElementById("download-label-" + detectedPlatform) |
| 63 .innerHTML; | 37 .textContent; |
| 64 | 38 |
| 65 heroDownloadButton.addEventListener("click", function(event) | 39 heroDownloadButton.addEventListener("click", function(event) |
| 66 { | 40 { |
| 67 if (!chrome) return; | 41 if (typeof chrome == "undefined") return; |
|
juliandoucette
2018/04/06 12:35:23
It's possible for chrome to exist without webstore
ire
2018/04/06 13:21:49
Agreed.
| |
| 68 event.preventDefault(); | 42 event.preventDefault(); |
| 69 chrome.webstore.install(); | 43 |
| 44 try | |
| 45 { | |
| 46 chrome.webstore.install(); | |
| 47 } | |
| 48 catch(error) | |
| 49 { | |
| 50 window.location = "/" + this.hreflang + "/download"; | |
| 51 } | |
| 70 }); | 52 }); |
| 71 } | 53 } |
| 72 | 54 |
| 73 if (bowser) setupHeroDownloadButton(); | 55 if (typeof bowser != "undefined") setupHeroDownloadButton(); |
| 74 | 56 |
| 75 }()); | 57 }()); |
| LEFT | RIGHT |