Add README.org, documentation and logging changes
This commit is contained in:
13
README.org
Normal file
13
README.org
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#+TITLE: yt-share-cleaner
|
||||||
|
#+AUTHOR: chase
|
||||||
|
#+OPTIONS: toc:nil
|
||||||
|
*yt-share-cleaner* is an extension that removes tracking from YouTube share links.
|
||||||
|
|
||||||
|
When using the `Share` button -> `Copy` button to copy the share link, YouTube
|
||||||
|
adds a tracking portion to the URL.
|
||||||
|
|
||||||
|
To deal with this annoyance, yt-share-cleaner:
|
||||||
|
1. runs whenever the mouse is clicked
|
||||||
|
2. reads the contents of the clipboard
|
||||||
|
3. if the clipboard has a YouTube share link, remove the tracking portion and
|
||||||
|
write the new URL to the clipboard
|
@@ -3,7 +3,7 @@
|
|||||||
"name": "yt-share-cleaner",
|
"name": "yt-share-cleaner",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
|
|
||||||
"description": "Cleans tracking from share URLs on YouTube",
|
"description": "remove tracking from YouTube share URLs",
|
||||||
|
|
||||||
"icons": {
|
"icons": {
|
||||||
"16": "icons/yt-share-cleaner-16.png",
|
"16": "icons/yt-share-cleaner-16.png",
|
||||||
|
@@ -15,16 +15,16 @@
|
|||||||
return(cleanedUrl)
|
return(cleanedUrl)
|
||||||
}
|
}
|
||||||
// return original url if it is not a share link
|
// return original url if it is not a share link
|
||||||
console.log("Not a share link, clipboard contents unmodified.")
|
|
||||||
return(url)
|
return(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
function sleep(ms) {
|
function sleep(ms) {
|
||||||
|
// sleep for half a second
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onMouseUp() {
|
async function onMouseUp() {
|
||||||
// wait half a second after clicking before reading clipboard
|
// delay clipboard read slightly because of page script nonsense
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
|
|
||||||
let clipText = await navigator.clipboard.readText();
|
let clipText = await navigator.clipboard.readText();
|
||||||
@@ -33,12 +33,13 @@
|
|||||||
if (clipText !== newText) {
|
if (clipText !== newText) {
|
||||||
const newClip = await navigator.clipboard.writeText(newText);
|
const newClip = await navigator.clipboard.writeText(newText);
|
||||||
console.log("Modified clipboard with cleaned share link: %o", newText);
|
console.log("Modified clipboard with cleaned share link: %o", newText);
|
||||||
clipText = undefined;
|
} else {
|
||||||
newText = undefined;
|
console.log("Share link not detected, clipboard contents unmodified.");
|
||||||
}
|
}
|
||||||
|
// discard clipboard data
|
||||||
clipText = undefined;
|
clipText = undefined;
|
||||||
newText = undefined;
|
newText = undefined;
|
||||||
}
|
}
|
||||||
|
// run whenever MOUSE1 is released
|
||||||
document.addEventListener('mouseup', onMouseUp, false);
|
document.addEventListener('mouseup', onMouseUp, false);
|
||||||
})();
|
})();
|
||||||
|
Reference in New Issue
Block a user