Index: static/js/index.js |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/static/js/index.js |
@@ -0,0 +1,49 @@ |
+"use strict"; |
+ |
+(function() |
+{ |
+ var supportedPlatforms = { |
+ |
+ // Desktop browsers |
+ "chrome": "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaibdccddilifddb", |
+ "opera": "https://addons.opera.com/extensions/details/opera-adblock/?display=en-US", |
+ "yandexbrowser": "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaibdccddilifddb", |
+ "msie": "https://update.adblockplus.org/latest/adblockplusie.exe", |
+ "msedge": "https://www.microsoft.com/store/p/adblock-plus/9nblggh4r9nz", |
+ "firefox": "https://update.adblockplus.org/latest/adblockplusfirefox.xpi", |
+ "safari": "https://update.adblockplus.org/latest/adblockplussafari.safariextz", |
+ "maxthon": "", |
+ |
+ // Mobile platforms |
+ "ios": "https://eyeo.to/adblockbrowser/ios/abp-website", |
+ "android": "https://eyeo.to/adblockbrowser/android/abp-website" |
+ }; |
+ |
+ function setupHeroDownloadButton() |
+ { |
+ var detectedPlatform = Object.keys(supportedPlatforms) |
+ .find(hasOwnProperty.bind(bowser)); |
juliandoucette
2018/04/06 16:29:16
Detail/TOL: I'm a little uncomfortable using `wind
ire
2018/04/09 09:24:01
Done.
|
+ |
+ if (!detectedPlatform) return; |
+ |
+ document.body.classList.add(detectedPlatform); |
+ |
+ if (detectedPlatform == "maxthon") return; |
+ |
+ var heroDownloadButton = document.getElementById("hero-download-button"); |
+ heroDownloadButton.href = supportedPlatforms[detectedPlatform]; |
+ heroDownloadButton.innerHTML = document |
+ .getElementById("hero-download-button-template") |
+ .innerHTML; |
+ |
+ heroDownloadButton.addEventListener("click", function(event) |
+ { |
+ if (!chrome || !chrome.webstore) return; |
juliandoucette
2018/04/06 16:29:17
This will cause a reference error if `chrome` is n
ire
2018/04/09 09:24:02
Done.
|
+ event.preventDefault(); |
+ chrome.webstore.install(); |
+ }); |
+ } |
+ |
+ if (bowser) setupHeroDownloadButton(); |
juliandoucette
2018/04/06 16:29:17
I think that this may also cause a reference error
ire
2018/04/09 09:24:02
Done.
|
+ |
+}()); |