Code: Select all
@@||youtube.com/*channel=TotalHalibut$document
Code: Select all
@@||youtube.com/*channel=TotalHalibut$document
Tried using this one through tampermonkey in Chrome, with "channel=https://www.youtube.com/user/TotalHalibut", then adding the following to the AdBlock Plus filter "@@||youtube.com/*user=TotalHalibut$document". After doing this, whenever I load a video on Youtube, it constantly refreshes, each time adding an extra segment onto the URL, eventually leading to an error about the /watch URL being too long. Am I doing something wrong, or has Youtube changed something?Vorondil wrote:When using the above javascript in GreaseMonkey for Firefox, it added a humongous text string in the URL-field that did not work. My guess is that the peopz behind Youtube have changed something recently, they tend to do that...
Anyhow, after some messing around with the script code I managed to get it to work for me, and I figured I'd share it with y'all.
I'm usually more of a C++/C#-programmer, and took myself the liberty of writing the code in a style i felt more legible. If I've made any serious Javascript faux pas, feel free to comment or alter as desired.
Vorondil out.Code: Select all
// ==UserScript== // @name Expose Youtube Uploader Name in URL // @namespace schippi // @description Used to expose a Youtube uploaders displayname in the URL // @include http://www.youtube.com/watch* // @include https://www.youtube.com/watch* // @version 1.2 // @grant none // ==/UserScript== // Credits go to Schippi and Dubious for doing the base work which I've modified here. var url = window.location.href; if ( url.search( "channel=" ) == -1 ) { if ( document.getElementById( "watch7-user-header" ) != null ) { var channelNameContainer = document.getElementsByClassName("yt-user-name")[0]; //var channelName = channelNameContainer.innerHTML; //The above 'channelName' is not used below. Could be an option instead of 'channelURL', but often contain spaces, and might not be unique. var channelURL = channelNameContainer.getAttribute("href"); channelURL = channelURL.replace( '/user/', '' ); //window.location.href = url + "&channel=" + channelName; //alterative for name insertion rather than channel-url. window.location.href = url + "&channel=" + channelURL; } }
Code: Select all
// ==UserScript==
// @name Expose Youtube Uploader Name in URL
// @namespace schippi
// @description Used to expose a Youtube uploaders displayname in the URL
// @include http://www.youtube.com/watch*
// @include https://www.youtube.com/watch*
// @version 1.3
// @grant none
// ==/UserScript==
// Credits go to Schippi and Dubious for doing the base work which I've modified here.
var setup = "user";
// only this /\ is to be edited depending on what you want.
// change "user" to "channel" if you wish to use the safer method of not unlocking ads for channels with same name
var url = window.location.href;
if ( url.search( "user=" ) == -1)
{
if ( document.getElementById( "watch7-user-header" ) != null )
{
var channelNameContainer = document.getElementsByClassName("yt-user-name")[0];
var channelName = channelNameContainer.innerHTML;
if(setup == "user")
{
channelName = channelName.replace( ' ', '' );
window.location.href = url + "&user=" + channelName;
};
if(setup == "channel")
{
var channelURL = channelNameContainer.getAttribute("href");
channelURL = channelURL.replace( '/channel/', '' );
window.location.href = url + "&user=" + channelURL;
};
}
}
that's the exception rule you have to add to adblock:DaJamsta123 wrote:So, I put that new code in, and am I right in saying you don't have to put a specific channel name in anywhere in that code? Without adding any channel names and leaving as is, the constant refresh stopped, and the channel name is now displayed at the top as something like "https://www.youtube.com/watch?v=zymf7o5 ... cal%20Brit". However, I can't seem to work out how to then add the filter to addblock plus.
Code: Select all
@@||youtube.com/watch*user=CHANNELNAMEOFYOURGUY$document
Code: Select all
@@||youtube.com/watch*user=TotalBiscuit$document
not filter, whitelist entry. (i think that's what you meant anyway ^^)DaJamsta123 wrote:One more question though, if I want to do this for other channels, do I just have to add another filter to AddBlock?
Code: Select all
@@||youtube.com/watch*user=Flaim$document
sorry, just looked at my adblock and you're right. they named it "filter" while in reality it is supposed to be called whitelist or exception...DaJamsta123 wrote:Adding this to the filter tab in AdBlock Plus seems to work, maybe it calls it something different because I'm in Chrome. There is another tab called Whitelisted Domains, but I should think that's just for normal URL's to be whitelisted. Oh wlee, what I have works, so thanks
Code: Select all
@@||youtube.com/watch*$elemhide
@@||googleads.g.doubleclick.net/*$domain=youtube.com
@@||pubads.g.doubleclick.net/*$domain=youtube.com
@@||googlesyndication.com/*$domain=youtube.com
Code: Select all
// ==UserScript==
// @name Expose Youtube Uploader Name in URL
// @namespace schippi
// @description Used to expose a Youtube uploaders displayname in the URL
// @include http://www.youtube.com/watch*
// @include https://www.youtube.com/watch*
// @version 1.4
// @grant none
// ==/UserScript==
// Credits go to Schippi and Dubious for doing the base work which I've modified here.
// only this /\ is to be edited depending on what you want.
// change "user" to "channel" if you wish to use the safer method of not unlocking ads for channels with same name
var url = window.location.href;
if (url.search('user=') == - 1)
{
if (document.getElementsByClassName('yt-user-info') != null)
{
var channelNameContainer = document.getElementsByClassName('yt-user-info')[0].getElementsByClassName(' yt-uix-sessionlink spf-link g-hovercard')[0];
var channelName = channelNameContainer.innerHTML;
window.location.href = url + '&user=' + channelName;
}
}
I haven't looked at the actual code, but just judging by the includes, it's not going to handle situations when the page content changes dynamically. I posted my own script to Greasy Fork back in mid-August; I recommend that one instead.Javert wrote:new working code: