sussy first commit
This commit is contained in:
parent
bcc88099ef
commit
5ebbe89764
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) <year> <copyright holders>
|
Copyright (c) 2023 Looki2000
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
|
12
README.md
12
README.md
@ -1,3 +1,13 @@
|
|||||||
# yt-main-page-videos-hider
|
# yt-main-page-videos-hider
|
||||||
|
|
||||||
Hides videos on the main page of YouTube
|
Hides videos on the main page of YouTube
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
1. Install Tampermonkey or Greasemonkey (not tested for Greasemonkey) for example from chrome web store
|
||||||
|
2. Click on your extension icon and then on "Create a new script..."
|
||||||
|
3. Paste script from the js file in this repo
|
||||||
|
4. Save (Ctrl+S or Cmd+S)
|
||||||
|
5. Done!
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
To temporarily disable the script, click on the extension icon and then switch off "YouTube main page remover"
|
63
yt_main_page_videos_hider.user.js
Normal file
63
yt_main_page_videos_hider.user.js
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
// ==UserScript==
|
||||||
|
// @name YouTube main page remover
|
||||||
|
// @version 1
|
||||||
|
// @description self explanatory
|
||||||
|
// @match *://www.youtube.com/*
|
||||||
|
// @grant none
|
||||||
|
// @run-at document-start
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
///// CONFIGURATION /////
|
||||||
|
|
||||||
|
const main_page_timeout = 1000 * 5; // timeout for removing main page videos element (in ms)
|
||||||
|
|
||||||
|
/////////////////////////
|
||||||
|
|
||||||
|
var main_page_div;
|
||||||
|
var start_time;
|
||||||
|
|
||||||
|
// Check if the url is https://www.youtube.com (main page) every second (stops when main page is already removed)
|
||||||
|
const interval_id = setInterval(function() {
|
||||||
|
console.log("url check loop running");
|
||||||
|
|
||||||
|
if (window.location.href == "https://www.youtube.com/") {
|
||||||
|
remove_main_page();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// function to try to remove main page videos element
|
||||||
|
function remove_main_page() {
|
||||||
|
console.log("starting to try to remove main page");
|
||||||
|
|
||||||
|
// stop interval loop
|
||||||
|
clearInterval(interval_id);
|
||||||
|
|
||||||
|
start_time = Date.now();
|
||||||
|
window.requestAnimationFrame(loop);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function loop() {
|
||||||
|
// check if main page videos element exists
|
||||||
|
main_page_div = document.querySelector("ytd-rich-grid-renderer > #contents");
|
||||||
|
|
||||||
|
// if it exists, remove it
|
||||||
|
console.log("trying to remove main page");
|
||||||
|
if (main_page_div) {
|
||||||
|
main_page_div.remove();
|
||||||
|
console.log("removed main page");
|
||||||
|
} else {
|
||||||
|
// check if the timeout has NOT been reached
|
||||||
|
if (Date.now() - start_time < main_page_timeout) {
|
||||||
|
window.requestAnimationFrame(loop);
|
||||||
|
} else {
|
||||||
|
console.log("main page timeout reached");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
Loading…
Reference in New Issue
Block a user