-
-
Save Tazeki/4474bc972710872c429e660a6b08681d to your computer and use it in GitHub Desktop.
// ==UserScript== | |
// @name URL Conversion | YouTube - HookTube | |
// @namespace Tazeki | |
// @description The smallest, possibly most useful YouTube-HookTube conversion script. RegEx based. Report bugs to [email protected]. Sends any /www.youtube.com/ sites to HookTube before page load. Does not affect /other.youtube.com/, (gaming.youtube.com, creatoracademy.youtube.com, etc.). | |
// @include *youtube* | |
// @version 1 | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
var url = window.location.toString(); | |
if (url.indexOf('www.youtube.com') !== - 1) { | |
window.location = url.replace(/youtube.com/, 'hooktube.com'); | |
} else if (url.indexOf('www.youtu.be') !== - 1) { | |
window.location = url.replace(/youtu.be/, 'hooktube.com'); | |
} |
With Firefox, go to about:config
and toggle media.autoplay.enabled
to false.
I found this code for other browsers, but I haven't checked it through:
// @name Pause all HTML5 videos on load
// @author Scuzzball
// @namespace http://userscripts.org/users/Scuzzball
// @description Pause autoplaying HTML5 videos on load. In Firefox just go into about:config and look for media.autoplay.enabled and set to false.
// @version 1
// @include http://www.youtube.com
// @include http://youtube.com
// ==/UserScript==
function stopVideo(){for(var e=0;e<videos.length;e++)videos[e].pause(),video.currentTime=0}function f(){try{var e=document.getElementById("autoplay-checkbox").parentNode.parentNode;"checkbox-on-off"==e.className&&e.parentNode.removeChild(e)}catch(o){}}var videos=document.getElementsByTagName("video");window.addEventListener("load",stopVideo,!1),f(),document.body.addEventListener("DOMSubtreeModified",f,!1);
Cheers,
Taz.
Could you make an exception in the script for youtube pages that do not contain any videos? Right now when I try to visit my subscription page (http://www.youtube.com/feed/subscriptions/u) I am redirected to a hooktube page that doesn't exist. It would be nice if I could still do that.
Here are my versions, I use them with Adguard for Windows as a user filter rule so they're one-liners:
1- simple version
checks for watch
and v=
code:
(function(){var a="hooktube.com",b=window.location.href;(function(){"use strict";var a=window.location.href;if(-1<a.indexOf("youtube.com")&&-1<a.indexOf("v=")&&-1<a.indexOf("watch")){window.location.href=a.replace("youtube.com","hooktube.com")}})();
2- my personal version:
- I don't like polymer UI of Youtube ,
so, I adddisable_polymer=true
- I don't like localized youtube (I don't login to youtube, and I reject cookies too)
so, I addhl=en&gl=US
- if watch parameter matches, there'll be a confirmation dialog asking to go to hooktube or stay.
code:
window.onload=(function(){"use strict";var a=function(){this.addr=window.location.href};a.prototype.has=function(d){return-1<this.addr.indexOf(d)},a.prototype.rp=function(){return this.addr=this.addr.replace("youtube.com","hooktube.com"),this},a.prototype.fixyt=function(){var d="hl=en&gl=US&disable_polymer=true";return this.addr=-1<this.addr.indexOf("?")?this.addr+"&"+d:this.addr+"?"+d,this},a.prototype.go=function(){window.location.href=this.addr};var b=new a;if(b.has("youtube.com")){var c=!b.has("disable_polymer");b.has("watch")&&c?confirm("go to hooktube?")?b.rp().go():c&&b.fixyt().go():c&&b.fixyt().go()}})();
Here comes my personal version as a user script with config options, you can state which url parts to redirect, confirm option, polymer, global etc ;
// ==UserScript==
// @name Yooktube
// @namespace http://localhost/
// @version 0.1
// @description Your Script
// @author nobody
// @match http*://*.youtube.com/*
// @runat document-start
// @grant none
// ==/UserScript==
(function() {
"use strict";
//do you want to disable_polymer UI?
var no_polymer = 1;
//do you want to force global content with US English?
var global_tube = 1;
//which URL parts to trigger a redirect to hooktube?
var redirparts = ["watch", "channel"];
//should ask for confirm before redirect?
var askconfirm = 1;
var np = "disable_polymer=true";
var gt = "hl=en&gl=US";
var tube = function htube() {
this.addr = window.location.href;
};
tube.prototype.has = function(y) {
if (Array.isArray(y)) {
for (var i = 0; i < y.length; i++) {
if (this.addr.indexOf(y[i]) > -1) return true;
}
} else {
return this.addr.indexOf(y) > -1;
}
return false;
};
tube.prototype.rp = function() {
var ht = "hooktube.com";
this.addr = this.addr.replace("youtube.com", ht);
return this;
};
tube.prototype.fixyt = function() {
var permitted = no_polymer + global_tube;
if (permitted > 0) {
var merger = permitted > 1 ? "&" : "";
var str = ((global_tube)? gt : "") + merger + ((no_polymer)? np : "");
var symb=(this.addr.indexOf("?") > -1) ? "&" : "?";
this.addr+= symb + str;
}
return this;
};
tube.prototype.go = function() {
window.location.href = this.addr;
};
var url = new tube();
var needfix = true;
var needredir = false;
if (url.has("youtube.com")) {
if ((url.has(np) && no_polymer) || (url.has(gt) && global_tube)) needfix = false;
if (url.has(redirparts) && needfix) needredir = true;
if (needredir) {
if (askconfirm) {
if (confirm("go to hooktube?")) {
url.rp().go();
} else {
if (needfix) {
url.fixyt().go();
}
}
} else {
url.rp().go();
}
} else {
if (needfix) {
url.fixyt().go();
}
}
}
})();
Are there instructions somewhere on how to use this? I suggest it would probably be a good thing. I bumbled around and made it work. Maybe this will some other poor, clueless person:
I'm using Pale Moon. I installed Guerilla Scripting (NOT mispelled) from here:
http://addons.palemoon.org/addon/guerilla-scripting/
Firefox users would probably find Grease Monkey would work the same way. Just guessing.
Then , after studying the content, I downloaded the raw file from here
to this directory:
/home/MY-USER-NAME/.moonchild productions/pale moon/MY-PROFILE-DIRECTORY-NAME/guerrillas/scripts
Firefox users will need to look up how to find their profile directory and maybe read a how to on Grease Monkey .
Works great.
Firefox users will need to look up how to find their profile directory and maybe read a how to on Grease Monkey .
Not at all, @Lew-Rockwell-Fan. Even someone like me, who only had one single script installed was able to do it just fine.
- Copy the piece of code created by Tazeki
- Go to GreaseMonkey and hit the "New User Script" button.
- In the new tab that opens, paste the code and hit the floppy disk/save button
- Test.
And that's it. It's extremely easy.
Oh wait, it already does. I think that it should be made to disable autoplay on embedded youtube videos.