diff --git a/.gitignore b/.gitignore index 15af1aa..bde2dfc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -*.xpi +/web-ext-artifacts diff --git a/.web-extension-id b/.web-extension-id new file mode 100644 index 0000000..33b567f --- /dev/null +++ b/.web-extension-id @@ -0,0 +1,3 @@ +# This file was created by https://github.com/mozilla/web-ext +# Your auto-generated extension ID for addons.mozilla.org is: +tubeproxy@netflux.io \ No newline at end of file diff --git a/bin/build.sh b/bin/build.sh new file mode 100755 index 0000000..b8d67e0 --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +read -p "Enter Mozilla API secret: " secret +web-ext sign --ignore-files bin/ --api-key=user:16805942:907 --api-secret="$secret" diff --git a/bin/test.sh b/bin/test.sh new file mode 100755 index 0000000..031224c --- /dev/null +++ b/bin/test.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +set -e +web-ext run --verbose diff --git a/build.sh b/build.sh deleted file mode 100755 index 743606d..0000000 --- a/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/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 index 20ee5c4..2457b59 100644 --- a/hook.js +++ b/hook.js @@ -1,24 +1,34 @@ // Based on: https://github.com/metiis/invidious-redirect/blob/master/makehook.js -const dest = "tube.netflux.io"; -let href = window.location.href; +function checkRedirect() { + const dest = "tube.netflux.io"; + let href = window.location.href; + + // do not redirect Youtube consent page + if (href.includes("consent.youtube.com")) { + return + } + + 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; + } -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; -} +checkRedirect()