feat: add scripts
This commit is contained in:
@ -24,20 +24,19 @@ function logDebug(...kwargs) {
|
||||
console.log(...kwargs);
|
||||
}
|
||||
|
||||
function getShortsId(videoPathName)
|
||||
{
|
||||
const shortPath = videoPathName.split("/")
|
||||
return shortPath[shortPath.length - 1]
|
||||
function getShortsId(videoPathName) {
|
||||
const shortPath = videoPathName.split("/");
|
||||
return shortPath[shortPath.length - 1];
|
||||
}
|
||||
|
||||
function redirectReplace() {
|
||||
window.location.replace("https://www.youtube.com/watch?v=" + getShortsId(window.location.pathname));
|
||||
window.location.replace(
|
||||
"https://www.youtube.com/watch?v=" + getShortsId(window.location.pathname),
|
||||
);
|
||||
}
|
||||
|
||||
function checkCurrentURL()
|
||||
{
|
||||
if (window.location.pathname.includes("/shorts/"))
|
||||
{
|
||||
function checkCurrentURL() {
|
||||
if (window.location.pathname.includes("/shorts/")) {
|
||||
logDebug("Shorts url detected, redirecting...");
|
||||
redirectReplace();
|
||||
}
|
||||
@ -46,22 +45,19 @@ function checkCurrentURL()
|
||||
// Should be run asap
|
||||
checkCurrentURL();
|
||||
|
||||
function replaceHrefURL(element)
|
||||
{
|
||||
if (element.href != null && element.href.includes("/shorts/"))
|
||||
{
|
||||
element.href = "/watch?v=" + getShortsId(element.href)
|
||||
function replaceHrefURL(element) {
|
||||
if (element.href != null && element.href.includes("/shorts/")) {
|
||||
element.href = "/watch?v=" + getShortsId(element.href);
|
||||
}
|
||||
}
|
||||
|
||||
function checkElements()
|
||||
{
|
||||
insertionQ(':is(#video-title, #thumbnail) ').every(function(element) {
|
||||
function checkElements() {
|
||||
insertionQ(":is(#video-title, #thumbnail) ").every(function (element) {
|
||||
replaceHrefURL(element);
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('yt-navigate-finish', checkCurrentURL);
|
||||
window.addEventListener("yt-navigate-finish", checkCurrentURL);
|
||||
// Replace addEventListener with our sus one.
|
||||
const o_addEventListener = window.addEventListener;
|
||||
const o_shady_addEventListener = window.__shady_addEventListener;
|
||||
@ -89,17 +85,21 @@ function f_addEventListener(eventName, callback) {
|
||||
// This event is made by SponsorBlock not Youtube so by default it will not run.
|
||||
// But this can speed up the page navigation process so i'll just keep it.
|
||||
const data = event.data;
|
||||
if (data.type == 'navigation' && data.pageType == 'shorts') {
|
||||
if (data.type == "navigation" && data.pageType == "shorts") {
|
||||
if (data.videoID == undefined) {
|
||||
return;
|
||||
}
|
||||
logDebug("Thank you SponsorBlock for this event :3");
|
||||
logDebug("Navigating to video...");
|
||||
if (window.location.pathname.includes("/shorts/")) {
|
||||
window.location.replace("https://www.youtube.com/watch?v=" + data.videoID);
|
||||
window.location.replace(
|
||||
"https://www.youtube.com/watch?v=" + data.videoID,
|
||||
);
|
||||
return;
|
||||
}
|
||||
window.location.assign("https://www.youtube.com/watch?v=" + data.videoID);
|
||||
window.location.assign(
|
||||
"https://www.youtube.com/watch?v=" + data.videoID,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -117,4 +117,4 @@ logDebug("Init fake addEventListener successful.");
|
||||
window.__shady_addEventListener = f_sus_addEventListener;
|
||||
logDebug("Init fake __shady_addEventListener successful.");
|
||||
checkElements();
|
||||
console.warn("Fuck you YouTube - NoShorts loaded.")
|
||||
console.warn("Fuck you YouTube - NoShorts loaded.");
|
||||
|
||||
Reference in New Issue
Block a user