![]() ![]() |
EDIT: Problem solved. (See post 12.) Hi, I wrote a youtube fixer script, that uniformly changes all URLs to end in "&feature=channel" so I can see at a glance which videos I have already watched, (link color turns purple properly) even if I clicked the video from my subscriptions box (&feature=sub) or a video response (&feature=watch_response_rev).
Thanks in advance,
This is the script: // ==UserScript==
// @name 3ICE's Youtube Link Uniformer
// @namespace http://3ice.hu/
// @description Replaces everything with "&feature=channel" (feature can be: chclk, dka, featured, fvhl, fvhr, fvsr, fvwk, geo, grec_index, mhum, mh, more_related, popular, related, spotlight, sub, topvideos, watch_response_rev, and watch_response)
// @include http://*.youtube.com/*
// @include http://youtube.com/*
// ==/UserScript==
var annoyances = [/*
"&feature=channel", "&feature=channel", (This is our uniform target.) */
"&feature=chclk", "&feature=chclk",/*
"&feature=dka", "&feature=dka", (See mh) */
"&feature=featured", "&feature=featured",
"&feature=fvhl", "&feature=fvhl",
"&feature=fvhr", "&feature=fvhr",
"&feature=fvsr", "&feature=fvsr",
"&feature=fvwk", "&feature=fvwk",
"&feature=geo", "&feature=geo",
"&feature=grec_index", "&feature=grec_index",/*
"&feature=mhum", "&feature=mhum", (See mh)
"&feature=mh", "&feature=mh", (Uses "?feature=" instead of "&feature=", only present on the menu-items anyway.)
"&feature=more_related", "&feature=more_related", (Not present onload, only after clicking "Show More".) */
"&feature=popular", "&feature=popular",
"&feature=related", "&feature=related",
"&feature=spotlight", "&feature=spotlight",
"&feature=sub", "&feature=sub",
"&feature=topvideos", "&feature=topvideos",
"&feature=watch_response_rev", "&feature=watch_response_rev",
"&feature=watch_response", "&feature=watch_response"
];
var links=document.getElementsByTagName('a');
for(var i=0; i<links.length; i++){
var a=links[i];
for(var j=0; j<annoyances.length; j++){
a.href=a.href.replace(annoyances[j],"&feature=channel");
}
if(a.href.indexOf("&feature=channel")==-1){
a.href=a.href+"&feature=channel";
}/*
if(a.href.indexOf("feature=")>0){
var debug=a.href+":"+a.href.indexOf("&feature=")+"\n"+debug;
}*/
}
for(var k=0; k<annoyances.length; k++){
if(document.location.href.indexOf(annoyances[k])>0){
document.location.href=document.location.href.replace(annoyances[k],"&feature=channel");
}
}
if(document.location.href.indexOf("&feature=channel")==-1 && document.location.href.slice(-1)!="/"){
document.location.href=document.location.href+"&feature=channel";
}/*
if(debug){
alert("Please notify 3ICE!\nThe following links were not handled:\n"+debug);
}*/
|
![]() ![]() |
You could try an |
![]() ![]() |
Maybe there is some misunderstanding here. Generally this script will run on all pages that have .youtube.com/ SOMEWHERE in the URL. Like
http://www.youtube.com/ http://www.someothersite.com/help/why.the.hell.am.I.on.youtube.com/index.php |
![]() ![]() |
Remember that changing includes / excludes in script code after installing the script doesn't do anything. You may have a http://* include when you have created that script and forgot to change it. Either install the script again or change includes in Manage Scripts window. |
![]() ![]() |
So my browser - Google Chrome - has built-in support for GreaseMonkey scripts. Yesterday I looked at the bug tracker for chrome and found nothing related. Googled it, found nothing except one article that is using @match instead of @include which I found quite weird. It must be an older article. I can't use @match anyway, as I want to release my script for Firefox users too. (I already have a very similar script that works fine and has the same @include pattern.) @ttyler333: Doesn't @exclude overwrite all @includes? My script wouldn't run anywhere if I excluded everything that begins with http. @devnull69: The script runs everywhere. Even at http://www.google.com/ And I still don't know why. @AmpliDude: I am reinstalling the code every time I change something in it. By the way I am coding my script in notepad, so there is no manage scripts button. (And my browser is Google Chrome, I forgot to mention that in my first post.) As a temporary fix I will try wrapping the whole script in an if/then/else block, comparing document.location.href to a regexp: EDIT: I ended up using |
![]() ![]() |
From the looks of it, doesn't seem at all that it should run on Google.com as well. Can you give us a link of the test script from where you are *actually* installing? We can try from there itself. I find the reason given by AmpliDude convincing. But if not, try removing everything and then installing, instead of just reinstalling the script (Or may be try removing Chrome itself :) ) |
![]() ![]() |
If it still keeps going you can just make a "if" with all the code in it. example:
if(location.href.match('youtube.com'))
{
.... execute all the code
}
|
![]() ![]() |
I ended up using document.location.href.match(/http:\/\/[a-zA-Z\.]*youtube\.com\//). |
![]() ![]() |
Chrome converts the userscript into a "minimalistic" extension. So you will find it in the Extension manager (Tool menu, Tools, Extensions). Find out its ID and open the following folder on your hard drive:
|
![]() ![]() |
3ICE sorry I didn't see your post above but anyways you don't even need to match anything more than the 'youtube' word. Meaning your doing unnecessary work. Anyways I'll look into your script later and check what's happening. EDIT: Site Example where your script executes besides youtube? I tried google.com like you said and it doesn't execute there... |
![]() ![]() |
I've tested your script with FF3.6 and it works fine. Blame Google/Chrome ;D PS: Make your description shorter, that's overkill^^ |
![]() ![]() |
@devnull69: Holy cow, that's it. This is the automatically generated manifest.json file for the newest version of my script: {
"content_scripts": [ {
"exclude_globs": [ ],
"include_globs": [ "*" ],
"js": [ "script.js" ],
"matches": [ "http://*/*", "https://*/*" ]
} ],
"converted_from_user_script": true,
"description": "",
"key": "92krVEqALfhkoyM6VjzYc3yX0rSeKRW+E3lVSppRC4=x",
"name": "3ICEsYoutubeLinkCleanerShortenerTrackingRemover.user.js",
"version": "1.0"
}Basically it includes every site... (*.*) Crazy.
Whats funny is that I've been there, and done (almost) that, but I ignored manifest.json and went straight for script.js. Which checked out fine. @Jiwe: Apparently this is a Chrome-only bug. But the script was also executed right here as well (http://userscripts.org/forums/), forcing me to disable it before I could even post my topic (All the links got a "&feature=channel" added to them, which broke some things. :) @Mewes Kochheim: The current version has this description: "Removes the annoying tracking parameter called "feature" from links on YouTube. (&feature=related and ~20 others)". (48.9% shorter!) This problem is now solved, thanks to devnull69. Conclusion: Google Chrome ignores the @include parameter(s) and puts the script in every page. Because it can, i guess.
|


