diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..15af1aa --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.xpi diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..fb8e9e3 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,7 @@ +Copyright © 2021 Rob Watson + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d45cee --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# tubeproxy + +A tiny browser extension to automatically redirect Youtube URLs to a personal Invidious instance. + + +## License + +MIT diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..743606d --- /dev/null +++ b/build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -e +zip out.zip hook.js manifest.json +mv out.zip out.xpi diff --git a/hook.js b/hook.js new file mode 100644 index 0000000..20ee5c4 --- /dev/null +++ b/hook.js @@ -0,0 +1,24 @@ +// Based on: https://github.com/metiis/invidious-redirect/blob/master/makehook.js + +const dest = "tube.netflux.io"; +let href = window.location.href; + +if (href.includes("m.youtube.com")) { + href = href.replace("m.youtube.com", dest); +} else if (href.includes("www.youtube.com")) { + href = href.replace("www.youtube.com", dest); +} else if (href.includes("youtu.be")) { + href = href.replace("youtu.be/", dest + "/watch?v="); +} + +if (href.includes("/results?q")) { + href = href.replace("/results?q", "/search?q"); +} + +if (href.includes("/results?search_query")) { + href = href.replace("/results?search_query", "/search?q"); +} + +if(confirm("Redirect to " + href + "?")) { + window.location.href = href; +} diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..49cfb10 --- /dev/null +++ b/manifest.json @@ -0,0 +1,20 @@ +{ + "manifest_version": 2, + "author": "Rob Watson", + "homepage_url": "https://git.netflux.io/rob/tubeproxy", + "version": "0.1", + "name": "tubeproxy", + "content_scripts": [ + { + "matches": ["*://*.youtube.com/*"], + "run_at": "document_start", + "js": ["hook.js"] + } + ], + "permissions": [], + "browser_specific_settings": { + "gecko": { + "id": "tubeproxy@netflux.io" + } + } +}