Add extension

This commit is contained in:
Rob Watson 2021-04-05 12:04:13 +02:00
parent b5eb92f6b1
commit 251ab898f7
6 changed files with 65 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.xpi

7
LICENSE.txt Normal file
View File

@ -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.

8
README.md Normal file
View File

@ -0,0 +1,8 @@
# tubeproxy
A tiny browser extension to automatically redirect Youtube URLs to a personal Invidious instance.
## License
MIT

5
build.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -e
zip out.zip hook.js manifest.json
mv out.zip out.xpi

24
hook.js Normal file
View File

@ -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;
}

20
manifest.json Normal file
View File

@ -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"
}
}
}