From eeef7f052bce6915a4227b886d4cb714c9672b05 Mon Sep 17 00:00:00 2001 From: SimonBrazell Date: Wed, 30 Oct 2019 16:48:38 +1100 Subject: Add instances to popup menu --- README.md | 6 +++++- images/Screen Shot 1.png | Bin 415406 -> 381934 bytes images/Screen Shot 2.png | Bin 811174 -> 804506 bytes images/Screen Shot 3.png | Bin 0 -> 240696 bytes manifest.json | 2 +- pages/popup/popup.html | 11 +++++++---- pages/popup/popup.js | 47 +++++++++++++++++++++++++++++++++++------------ web-ext-config.js | 1 + 8 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 images/Screen Shot 3.png diff --git a/README.md b/README.md index e2ad837b..4a38b52e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,11 @@ - [Chrome Extension](https://chrome.google.com/webstore/detail/privacy-redirect/pmcmeagblkinmogikoikkdjiligflglb) - [Firefox Add-on](https://addons.mozilla.org/en-US/firefox/addon/privacy-redirect/) -A simple browser extension to redirect Twitter & Youtube requests to [Nitter](https://nitter.net/about) & [Invidious](https://www.invidio.us/), works when navigating to the site, or opening links. +A simple browser extension that redirects Twitter & Youtube requests to privacy friendly alternatives - [Nitter](https://github.com/zedeus/nitter) & [Invidious](https://github.com/omarroth/invidious). + +No unnecessary permissions required, only listens for and redirects requests made to twitter.com, www.twitter.com, mobile.twitter.com, youtube.com, www.youtube.com, youtube-nocookie.com, www.youtube-nocookie.com, and m.youtube.com, nothing else. + +Allows for setting custom [Nitter](https://github.com/zedeus/nitter/wiki/Instances) & [Invidious](https://github.com/omarroth/invidious/wiki/Invidious-Instances) instances and toggling redirects on & off. ## Build diff --git a/images/Screen Shot 1.png b/images/Screen Shot 1.png index 7363026a..c5ae2277 100644 Binary files a/images/Screen Shot 1.png and b/images/Screen Shot 1.png differ diff --git a/images/Screen Shot 2.png b/images/Screen Shot 2.png index f131363d..cb7c6410 100644 Binary files a/images/Screen Shot 2.png and b/images/Screen Shot 2.png differ diff --git a/images/Screen Shot 3.png b/images/Screen Shot 3.png new file mode 100644 index 00000000..4d46108b Binary files /dev/null and b/images/Screen Shot 3.png differ diff --git a/manifest.json b/manifest.json index d2c20b0b..629bfaef 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "Privacy Redirect", "description": "Redirects Twitter & Youtube requests to privacy friendly alternatives (Nitter & Invidious).", - "version": "1.1.1", + "version": "1.1.2", "manifest_version": 2, "background": { "scripts": [ diff --git a/pages/popup/popup.html b/pages/popup/popup.html index 889ffcde..22ccb025 100644 --- a/pages/popup/popup.html +++ b/pages/popup/popup.html @@ -14,7 +14,7 @@ Privacy Redirect logo - Version: 1.1.1 + Version: 1.1.2 @@ -36,9 +36,12 @@ - +
+

Nitter Instance

+ +

Invidious Instance

+ +
diff --git a/pages/popup/popup.js b/pages/popup/popup.js index 2837cdb2..799b5ea3 100644 --- a/pages/popup/popup.js +++ b/pages/popup/popup.js @@ -2,27 +2,50 @@ let disableNitter = document.querySelector('#disableNitter'); let disableInvidious = document.querySelector('#disableInvidious'); +let nitterInstance = document.querySelector('#nitterInstance'); +let invidiousInstance = document.querySelector('#invidiousInstance'); chrome.storage.sync.get( - ['disableNitter', 'disableInvidious'], - (result) => { + ['disableNitter', 'disableInvidious', 'nitterInstance', 'invidiousInstance'], + result => { disableNitter.checked = !result.disableNitter; disableInvidious.checked = !result.disableInvidious; + nitterInstance.value = result.nitterInstance || ''; + invidiousInstance.value = result.invidiousInstance || ''; } ); -disableNitter.addEventListener('change', (event) => { +function debounce(func, wait, immediate) { + let timeout; + return function () { + let context = this, args = arguments; + let later = function () { + timeout = null; + if (!immediate) func.apply(context, args); + }; + let callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) func.apply(context, args); + }; +}; + +let nitterInstanceChange = debounce(() => { + chrome.storage.sync.set({ nitterInstance: nitterInstance.value }); +}, 500); + +nitterInstance.addEventListener('input', nitterInstanceChange); + +let invidiousInstanceChange = debounce(() => { + chrome.storage.sync.set({ invidiousInstance: invidiousInstance.value }); +}, 500); + +invidiousInstance.addEventListener('input', invidiousInstanceChange); + +disableNitter.addEventListener('change', event => { chrome.storage.sync.set({ disableNitter: !event.target.checked }); }); -disableInvidious.addEventListener('change', (event) => { +disableInvidious.addEventListener('change', event => { chrome.storage.sync.set({ disableInvidious: !event.target.checked }); }); - -document.querySelector('#options').addEventListener('click', () => { - if (chrome.runtime.openOptionsPage) { - chrome.runtime.openOptionsPage(); - } else { - window.open(chrome.runtime.getURL('../options/options.html')); - } -}); \ No newline at end of file diff --git a/web-ext-config.js b/web-ext-config.js index abbcbf12..29a5243a 100644 --- a/web-ext-config.js +++ b/web-ext-config.js @@ -1,5 +1,6 @@ module.exports = { ignoreFiles: [ 'images/Screen*.png', + 'images/small-tile.png' ], }; -- cgit 1.4.1