From c4f7972f2b6aa6a8017f0ee7476f4c91495e2600 Mon Sep 17 00:00:00 2001 From: Mihai Branescu Date: Wed, 8 Apr 2020 15:49:21 +0300 Subject: [PATCH] For #6558 - added web extension for extracting document urls --- app/src/main/assets/extensions/ads/ads.js | 17 +++++++++++++ .../main/assets/extensions/ads/manifest.json | 24 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 app/src/main/assets/extensions/ads/ads.js create mode 100644 app/src/main/assets/extensions/ads/manifest.json diff --git a/app/src/main/assets/extensions/ads/ads.js b/app/src/main/assets/extensions/ads/ads.js new file mode 100644 index 0000000000..28b6f13f7e --- /dev/null +++ b/app/src/main/assets/extensions/ads/ads.js @@ -0,0 +1,17 @@ +function collect_urls(urls) { + let anchors = document.getElementsByTagName("a"); + for (let anchor of anchors) { + if (!anchor.href) { + continue; + } + urls.push(anchor.href); + } +} +let urls = []; +collect_urls(urls) + +let message = { + 'url': document.location.href, + 'urls': urls +} +browser.runtime.sendNativeMessage("MozacBrowserAds", message); diff --git a/app/src/main/assets/extensions/ads/manifest.json b/app/src/main/assets/extensions/ads/manifest.json new file mode 100644 index 0000000000..bfbdfeee49 --- /dev/null +++ b/app/src/main/assets/extensions/ads/manifest.json @@ -0,0 +1,24 @@ +{ + "manifest_version": 2, + "name": "Mozilla Android Components - Ads", + "version": "1.0", + "content_scripts": [ + { + "matches": ["https://*/*"], + "include_globs": [ + "https://www.google.*/search*", + "https://www.baidu.com/s*", + "https://www.baidu.com/baidu*", + "https://*search.yahoo.com/search*", + "https://www.bing.com/search*", + "https://duckduckgo.com/*" + ], + "js": ["ads.js"], + "run_at": "document_end" + } + ], + "permissions": [ + "geckoViewAddons", + "nativeMessaging" + ] +}