clean up and redirects
This commit is contained in:
parent
002fb6ce3f
commit
6b9b00243a
6 changed files with 38 additions and 27 deletions
20
altspeed.js
20
altspeed.js
|
@ -1,20 +0,0 @@
|
|||
(() => {
|
||||
let target = null;
|
||||
|
||||
window.addEventListener("keydown", e => {
|
||||
if(e.key !== "Alt") return;
|
||||
const active = document.activeFocus ?? document.activeElement;
|
||||
const vid = active?.querySelector("video");
|
||||
if(!vid) return;
|
||||
vid.playbackRate = 2.5; // change to whatever you like
|
||||
target = vid;
|
||||
});
|
||||
|
||||
window.addEventListener("keyup", e => {
|
||||
if(e.key !== "Alt") return;
|
||||
if(!target) return;
|
||||
target.playbackRate = 1;
|
||||
target = null;
|
||||
});
|
||||
})();
|
||||
|
|
@ -6,7 +6,7 @@ console.log("hi");
|
|||
chrome.commands.onCommand.addListener(async (command) => {
|
||||
switch(command) {
|
||||
case "pip": {
|
||||
run(await getTab(), "pip.js");
|
||||
run(await getTab(), "content.js");
|
||||
break;
|
||||
}
|
||||
case "nextTab":
|
||||
|
@ -26,12 +26,6 @@ chrome.commands.onCommand.addListener(async (command) => {
|
|||
}
|
||||
});
|
||||
|
||||
// ran on every tab
|
||||
chrome.tabs.onUpdated.addListener((tab, { status }) => {
|
||||
if(status !== "complete") return;
|
||||
run(tab, "altspeed.js");
|
||||
});
|
||||
|
||||
// auto hide shelf
|
||||
let downloads = 0;
|
||||
chrome.downloads.onCreated.addListener(() => {
|
||||
|
|
|
@ -19,6 +19,14 @@
|
|||
"background": {
|
||||
"service_worker": "background.js"
|
||||
},
|
||||
"content_scripts": [{
|
||||
"matches": ["https://*/*", "http://*/*"],
|
||||
"run_at": "document_start",
|
||||
"js": [
|
||||
"scripts/redirect.js",
|
||||
"scripts/altspeed.js"
|
||||
]
|
||||
}],
|
||||
"commands": {
|
||||
"pip": {
|
||||
"suggested_key": "Alt+P",
|
||||
|
|
18
scripts/altspeed.js
Normal file
18
scripts/altspeed.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
let target = null;
|
||||
|
||||
window.addEventListener("keydown", e => {
|
||||
if(e.key !== "Alt") return;
|
||||
const active = document.activeFocus ?? document.activeElement;
|
||||
const vid = active?.querySelector("video");
|
||||
if(!vid) return;
|
||||
vid.playbackRate = 2.5; // change to whatever you like
|
||||
target = vid;
|
||||
});
|
||||
|
||||
window.addEventListener("keyup", e => {
|
||||
if(e.key !== "Alt") return;
|
||||
if(!target) return;
|
||||
target.playbackRate = 1;
|
||||
target = null;
|
||||
});
|
||||
|
11
scripts/redirect.js
Normal file
11
scripts/redirect.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const redirects = new Map();
|
||||
const instance = "yewtu.be";
|
||||
// redirects.set("m.youtube.com", instance);
|
||||
// redirects.set("www.youtube.com", instance);
|
||||
// redirects.set("youtube.com", instance);
|
||||
redirects.set("crates.io", "lib.rs");
|
||||
|
||||
const host = location.hostname;
|
||||
if(redirects.has(host))
|
||||
location.hostname = redirects.get(host);
|
||||
|
Loading…
Reference in a new issue