Advertisement
gur111

Youtube Channels Auto Switch to Videos

Nov 27th, 2022 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | Fixit | 0 0
  1. // if(document.URL.indexOf("youtube.com/@") >= 0 && document.URL.endsWith("featured") >= 0) {
  2. function getChildIndex(node) {
  3. return Array.prototype.indexOf.call(node.parentNode.childNodes, node);
  4. }
  5.  
  6.  
  7. function switchToVideos() {
  8. console.log('Got tab switch event, checking if need to switch to videos');
  9. let tabInd = getChildIndex(document.getElementsByClassName("style-scope ytd-c4-tabbed-header-renderer iron-selected")[0]);
  10. if(document.URL.indexOf("youtube.com/@") >= 0
  11. && tabInd < 4) {
  12. document.getElementById("tabsContent").children[3].click()
  13. } else {
  14. console.log('No need to switch. ind of @: ', document.URL.indexOf("youtube.com/@"),
  15. '\nTab index: ', tabInd);
  16. }
  17. }
  18.  
  19.  
  20.  
  21. document.addEventListener("yt-navigate-finish", ()=>setTimeout(()=>switchToVideos(), 400));
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement