Last active
December 19, 2018 00:41
-
-
Save vsubhash/8435b34e72f50e050f1d613f702b9fe6 to your computer and use it in GitHub Desktop.
Changes the profile link to the videos page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name YouTube Profile-Link-To-Vidoes-List Changer | |
// @namespace com.vsubhash.js.youtube-profile-link-to-videos-changer | |
// @description Changes the profile link to the videos page | |
// @include https://www.youtube.com/watch* | |
// @version 2018 | |
// @grant none | |
// ==/UserScript== | |
document.addEventListener("DOMContentLoaded", startItDelayed, false); | |
function startItDelayed() { | |
window.setTimeout(changeProfileLink, 4*1000); | |
} | |
function changeProfileLink() { | |
console.log("Executing YouTube Profile-Link-To-Vidoes-List Changer") | |
var oDivs = document.getElementsByTagName("div"); | |
if ((oDivs != null) && (oDivs.length > 0)) { | |
for (var i = 0; i < oDivs.length; i++) { if (oDivs[i].className == "yt-user-info") { | |
//console.log("YRFG Error: Here"); | |
var oAnchors = oDivs[i].getElementsByTagName("a"); | |
if ((oAnchors != null) && (oDivs.length>1)) { | |
var bFound = false; | |
for (var j = 0; j < oAnchors.length; j++) { | |
//console.log("YRFG Error: " + oAnchors[j].href.substring(0, "https://www.youtube.com/channel/".length)); | |
if (oAnchors[j].href.substring(0, "https://www.youtube.com/channel/".length) == "https://www.youtube.com/channel/") { | |
oAnchors[j].href = oAnchors[j].href + "/videos"; | |
bFound = true; | |
break; | |
} | |
} | |
if (bFound) { break; } | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment