From 830e7a60ce73596ca434b08d614b4350c0bc8639 Mon Sep 17 00:00:00 2001 From: Sv443 <38158426+Sv443@users.noreply.github.com> Date: Mon, 9 Jul 2018 13:19:32 +0200 Subject: [PATCH] [1.5.0] sorted settings - added video tag display in the description - added hotkey to switch between /watch and /embed to maximize player size --- TamperTubePlus.js | 796 ++++++++++++++++++++++++++-------------------- 1 file changed, 458 insertions(+), 338 deletions(-) diff --git a/TamperTubePlus.js b/TamperTubePlus.js index ec0a0be..9d5c624 100644 --- a/TamperTubePlus.js +++ b/TamperTubePlus.js @@ -1,9 +1,11 @@ // ==UserScript== // @name TamperTubePlus +// @version 1.5.0 +// @description New YouTube features and improvements // @namespace https://github.com/Sv443/TamperTubePlus -// @version 1.4.1 -// @description New YouTube features and general improvements // @author Sv443 +// @license MIT +// @copyright 2018, Sv443 (https://github.com/Sv443) // @match http*://www.youtube.com/* // @grant GM_addStyle // @grant unsafeWindow @@ -16,36 +18,71 @@ // @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js // @connect self // @connect * -// @connect sv443.net -// @license MIT -// @copyright 2018, Sv443 (https://github.com/Sv443) +// @downloadURL https://raw.githubusercontent.com/Sv443/TamperTubePlus/master/TamperTubePlus.js +// @updateURL https://raw.githubusercontent.com/Sv443/TamperTubePlus/master/TamperTubePlus.js // ==/UserScript== + + /*===============================<------------------------------------------------------------------------------>===============================*/ /*===============================< TamperTubePlus - handwritten by Sv443/Sven Fehler (https://github.com/Sv443) >===============================*/ /*===============================<------------------------------------------------------------------------------>===============================*/ +/* /¯¯¯¯¯¯¯¯¯¯¯¯\ /¯¯¯¯¯¯¯¯¯¯¯¯\ /¯¯¯¯¯¯¯¯¯¯\ + | | | | | ___ | + \___ ___/ \___ ___/ | | | | + | | | | | ¯¯¯ | + | | | | | _____/ + | | | | | / + | | | | | | + | | | | | | + \____/ \____/ \____/ +*/ + + + + -/*Settings Settings Settings Settings Settings*/ -// you can change these settings if you want to: + + +/*\ \ \ Settings Settings Settings Settings / / /*/ +/* \ \ \ Settings Settings Settings Settings Settings / / / */ +/* / / / Settings Settings Settings Settings \ \ \ */ +/*/ / / Settings Settings Settings Settings Settings \ \ \*/ + + + + +// Other + var ttp_language = "en"; // change TTP's language (default: "en" (english)), ("en" for english, "de" for german) -var log_to_console = false; // log some debug info to the javascript console if set to true (default: false) -var enable_version_watermark = true; // enable or disable the version watermark in the bottom left corner of your window, UI needs to be enabled for the watermark to show up (default: true) -var disable_polymer_design = true; // disables the new forced polymer design if set to true (default: false) - to return to the new youtube design, disable this option and clear all cookies on youtube -var enable_ui = true; // enable the user interface with buttons and additional information (default: true), menu can only be accessed if the ui is enabled -var button_color = "red"; // change the ui button colors (default: "red"), (possible: "red", "orange", "blue", "green") +var log_to_console = false; // log some debug info to the javascript console if set to true (default: false), (possible: true, false) +var search_engine = "google"; // change search engine for quick search (default: "google") (possible: "disable", "google", "ecosia" (plant trees through searches), "duckduckgo", "bing", "yahoo") + + + +// Visual Stuff + +var enable_version_watermark = true; // enable or disable the version watermark in the bottom left corner of your window, UI needs to be enabled for the watermark to show up (default: true), (possible: true, false) +var disable_polymer_design = false; // disables the new forced polymer design if set to true - to return to the new youtube design, disable this option and clear all cookies on youtube (default: false), (possible: true, false) +var show_tags_in_description = true; // shows the video's tags in the description (currently not available for polymer design) (due to limitations you'll need to reload the page after you switch to a new video to see the correct tags) (default: true), (possible: true, false) +var enable_ui = true; // enable the user interface with buttons and additional information, menu can only be accessed if the ui is enabled (default: true), (possible: true, false) +var button_color = "red"; // change the ui button color (default: "red"), (possible: "red", "orange", "blue", "green") var button_size = "normal"; // change the size of the ui buttons (default: "normal"), (possible: "small" (20px * 20px), "normal" (25px * 25px), "large" (35px * 35px)) +var closemenu_button_position = "right"; // on which side at the top the menu close button should be (default: "right"), (possible: "left", "right") +var stylesheet = 0; // switch through stylesheets for YouTube (default: 0) (0: disabled) (1: AdvancedYT - improved design and bigger video player for old youtube design) + + + +// Hotkeys + var download_hotkey = 119; // hotkey for quick video download (default key: F8 (119), 0 to disable), to look up key codes go to this website: https://tinyurl.com/y73b8h3z var search_hotkey = 115; // hotkey for quick search (default key: F4 (115), 0 to disable), to look up key codes go to this website: https://tinyurl.com/y73b8h3z var radio_hotkey = 113; // hotkey to activate the video's radio mix playlist (default key: F2 (113), 0 to disable), to look up key codes go to this website: https://tinyurl.com/y73b8h3z +var player_switch_hotkey = 107; // hotkey to switch between even bigger theater player or normal player (default key: [NUMPAD] ADD (107), 0 to disable), to look up key codes go to this website: https://tinyurl.com/y73b8h3z var closemenu_hotkey = 27; // hotkey to close the TTP menu (default key: ESC (27), 0 to disable (you can still click on the X)), to look up key codes go to this website: https://tinyurl.com/y73b8h3z -var closemenu_button_position = "right"; // on which side at the top the menu close button should be (default: "right") (possible: "left", "right") -var search_engine = "google"; // change search engine for quick search (default: "google") (possible: "disable", "google", "ecosia" (plant trees through searches), "duckduckgo", "bing", "yahoo") -var stylesheet = 0; // switch through stylesheets for YouTube (default: 0) (0: disabled) (1: AdvancedYT - improved design and bigger video player for old youtube design) - - @@ -62,10 +99,9 @@ var stylesheet = 0; // switch through stylesheets for YouTube (default: 0) (0: d /*Changelog Changelog Changelog Changelog Changelog*/ // what's new in this version: -// - added basic menu design -// - added menu closing through hotkey or button -// - changed TTP icon to a pixel art version because i really got into pixel art -// - added ecosia search engine to plant trees through searches +// - sorted settings +// - added video tag display in the description +// - added hotkey to switch between /watch and /embed to maximize player size @@ -81,68 +117,70 @@ var stylesheet = 0; // switch through stylesheets for YouTube (default: 0) (0: d (function () { - 'use strict'; - - /*Init Init Init*/ - - var curversion = "1.4.1"; - var error_content = ""; - var URLhost = window.location.host; - var URLpath = window.location.pathname; - var curURL = URLhost + "" + URLpath; - var queryString = window.location.search; - queryString = queryString.substring(1); - var watermarkcontent = ""; - - console.log("TamperTubePlus v" + curversion + " - by Sv443 / Sven Fehler - GitHub: https://github.com/sv443/"); //ttp_version is defined through the @require línk - console.log("Debug enabled: " + log_to_console); - if (log_to_console) { +'use strict'; + +/*Init Init Init*/ + +var curversion = "1.5.0"; +var error_content = ""; +var URLhost = window.location.host; +var URLpath = window.location.pathname; +var curURL = URLhost + "" + URLpath; +var queryString = window.location.search; +queryString = queryString.substring(1); +var watermarkcontent = ""; + +console.log("TamperTubePlus v" + curversion + " - by Sv443 / Sven Fehler - GitHub: https://github.com/sv443/"); +console.log("TamperTube Plus - Debug enabled: " + log_to_console); +if(log_to_console) { console.log("--BEGIN TamperTubePlus Debug"); - } +} - /*Languages Languages Languages*/ +/*Languages Languages Languages*/ - var lang_dl_format; - var lang_confirm_dl_retry; - var lang_enter_search_string; - var lang_no_mix_pl; - switch (ttp_language) { +var lang_dl_format; +var lang_confirm_dl_retry; +var lang_enter_search_string; +var lang_no_mix_pl; +switch (ttp_language) { case "en": - lang_dl_format = "Download video - choose format\nAvailable Options: mp3,m4a,aac,flac,ogg,wma,mp4,avi,wmv,3gp"; - lang_confirm_dl_retry = "Entered value does not match available file formats (mp3,m4a,aac,flac,ogg,wma,mp4,avi,wmv,3gp)\nTry again?"; - lang_enter_search_string = "Enter search string:"; - lang_no_mix_pl = "This video doesn't have a mix playlist available"; - if (log_to_console) { - console.log(" loaded english language"); - } - break; + chlang("en"); + break; case "de": - lang_dl_format = "Video herunterladen - Format auswählen\nVerfügbare Formate: mp3,m4a,aac,flac,ogg,wma,mp4,avi,wmv,3gp"; - lang_confirm_dl_retry = "Eingegebenes Format entspricht nicht den verfügbaren Formaten (mp3,m4a,aac,flac,ogg,wma,mp4,avi,wmv,3gp)\nTry again?"; - lang_enter_search_string = "Suchbegriff eingeben:"; - lang_no_mix_pl = "Dieses Video hat keine verfügbare Mix-Playlist"; - if (log_to_console) { - console.log(" loaded german language"); - } + chlang("de"); break; default: - error_content = "incorrect language value was chosen in the settings - loading english language instead"; - lang_dl_format = "Download video - choose format\nAvailable Options: mp3,m4a,aac,flac,ogg,wma,mp4,avi,wmv,3gp"; - lang_confirm_dl_retry = "Entered value does not match available file formats (mp3,m4a,aac,flac,ogg,wma,mp4,avi,wmv,3gp)\nTry again?"; - lang_enter_search_string = "Enter search string:"; - lang_no_mix_pl = "This video doesn't have a mix playlist available"; - if (log_to_console) { - console.log(" incorrect value was chosen in the settings - loading english language"); - } - break; - } + chlang("en"); + break; +} + +function chlang(lang){ + if(lang == "en"){ + lang_dl_format = "Download video - choose format\nAvailable Options: mp3,m4a,aac,flac,ogg,wma,mp4,avi,wmv,3gp"; + lang_confirm_dl_retry = "Entered value does not match available file formats (mp3,m4a,aac,flac,ogg,wma,mp4,avi,wmv,3gp)\nTry again?"; + lang_enter_search_string = "Enter search string:"; + lang_no_mix_pl = "This video doesn't have a mix playlist available"; + if(log_to_console) { + console.log(" loaded english language"); + } + } + else if(lang == "de"){ + lang_dl_format = "Video herunterladen - Format auswählen\nVerfügbare Formate: mp3,m4a,aac,flac,ogg,wma,mp4,avi,wmv,3gp"; + lang_confirm_dl_retry = "Eingegebenes Format entspricht nicht den verfügbaren Formaten (mp3,m4a,aac,flac,ogg,wma,mp4,avi,wmv,3gp)\nErneut versuchen?"; + lang_enter_search_string = "Suchbegriff eingeben:"; + lang_no_mix_pl = "Dieses Video hat keine verfügbare Mix-Playlist"; + if(log_to_console) { + console.log(" loaded german language"); + } + } +} - /*Disable Polymer Disable Polymer Disable Polymer*/ +/*Disable Polymer Disable Polymer Disable Polymer*/ - if (disable_polymer_design) { +if(disable_polymer_design) { // this script is not made nor handwritten by me but by Artain on GreasyFork (https://greasyfork.org/en/scripts/32906-get-me-old-youtube) function start() { var cookie = getPref(), @@ -190,142 +228,140 @@ var stylesheet = 0; // switch through stylesheets for YouTube (default: 0) (0: d return "noPref"; } start(); - } +} - /*UI Elements UI Elements UI Elements*/ +/*UI Elements UI Elements UI Elements*/ - var imgpathmp3;var imgpathspacer;var imgpathmp4;var imgpathmenu;var buttonsize; - switch (button_size) { // (0 = small (20px * 20px), 1 = normal (25px * 25px), 2 = large (35px * 35px)) +var imgpathmp3;var imgpathspacer;var imgpathmp4;var imgpathmenu;var buttonsize; +switch (button_size) { // (0 = small (20px * 20px), 1 = normal (25px * 25px), 2 = large (35px * 35px)) case "small": - buttonsize = 20; - if (log_to_console) { - console.log(" loaded button size of 20px"); - } - break; + buttonsize = 20; + if(log_to_console) { + console.log(" loaded button size of 20px"); + } + break; case "normal": - buttonsize = 25; - if (log_to_console) { - console.log(" loaded button size of 25px"); - } - break; + buttonsize = 25; + if(log_to_console) { + console.log(" loaded button size of 25px"); + } + break; case "large": - buttonsize = 35; - if (log_to_console) { - console.log(" loaded button size of 35px"); - } - break; + buttonsize = 35; + if(log_to_console) { + console.log(" loaded button size of 35px"); + } + break; default: - buttonsize = 25; - error_content = "incorrect button size value was chosen in the settings - loading default size of 25px instead"; - if (log_to_console) { - console.log(" incorrect value was chosen in the settings - loading default button size of 25px"); - } - break; - } - switch (button_color) { + buttonsize = 25; + error_content = "incorrect button size value was chosen in the settings - loading default size of 25px instead"; + if(log_to_console) { + console.log(" incorrect value was chosen in the settings - loading default button size of 25px"); + } + break; +} +switch (button_color) { case "orange": - imgpathmp3 = "https://sv443.github.io/code/resources/images/buttonleftmp3.png"; - imgpathspacer = "https://sv443.github.io/code/resources/images/buttonmiddleraw.png"; - imgpathmp4 = "https://sv443.github.io/code/resources/images/buttonrightmp4.png"; - imgpathmenu = "https://sv443.github.io/code/resources/images/buttonmiddlemenu.png"; - if (log_to_console) { - console.log(" loaded default (orange) button design"); - } - break; + imgpathmp3 = "https://sv443.github.io/code/resources/images/buttonleftmp3.png"; + imgpathspacer = "https://sv443.github.io/code/resources/images/buttonmiddleraw.png"; + imgpathmp4 = "https://sv443.github.io/code/resources/images/buttonrightmp4.png"; + imgpathmenu = "https://sv443.github.io/code/resources/images/buttonmiddlemenu.png"; + if(log_to_console) { + console.log(" loaded default (orange) button design"); + } + break; case "blue": - imgpathmp3 = "https://sv443.github.io/code/resources/images/buttonleftmp3_blue.png"; - imgpathspacer = "https://sv443.github.io/code/resources/images/buttonmiddleraw_blue.png"; - imgpathmp4 = "https://sv443.github.io/code/resources/images/buttonrightmp4_blue.png"; - imgpathmenu = "https://sv443.github.io/code/resources/images/buttonmiddlemenu_blue.png"; - if (log_to_console) { - console.log(" loaded blue button design"); - } - break; + imgpathmp3 = "https://sv443.github.io/code/resources/images/buttonleftmp3_blue.png"; + imgpathspacer = "https://sv443.github.io/code/resources/images/buttonmiddleraw_blue.png"; + imgpathmp4 = "https://sv443.github.io/code/resources/images/buttonrightmp4_blue.png"; + imgpathmenu = "https://sv443.github.io/code/resources/images/buttonmiddlemenu_blue.png"; + if(log_to_console) { + console.log(" loaded blue button design"); + } + break; case "green": - imgpathmp3 = "https://sv443.github.io/code/resources/images/buttonleftmp3_green.png"; - imgpathspacer = "https://sv443.github.io/code/resources/images/buttonmiddleraw_green.png"; - imgpathmp4 = "https://sv443.github.io/code/resources/images/buttonrightmp4_green.png"; - imgpathmenu = "https://sv443.github.io/code/resources/images/buttonmiddlemenu_green.png"; - if (log_to_console) { - console.log(" loaded green button design"); - } - break; + imgpathmp3 = "https://sv443.github.io/code/resources/images/buttonleftmp3_green.png"; + imgpathspacer = "https://sv443.github.io/code/resources/images/buttonmiddleraw_green.png"; + imgpathmp4 = "https://sv443.github.io/code/resources/images/buttonrightmp4_green.png"; + imgpathmenu = "https://sv443.github.io/code/resources/images/buttonmiddlemenu_green.png"; + if(log_to_console) { + console.log(" loaded green button design"); + } + break; case "red": - imgpathmp3 = "https://sv443.github.io/code/resources/images/buttonleftmp3_red.png"; - imgpathspacer = "https://sv443.github.io/code/resources/images/buttonmiddleraw_red.png"; - imgpathmp4 = "https://sv443.github.io/code/resources/images/buttonrightmp4_red.png"; - imgpathmenu = "https://sv443.github.io/code/resources/images/buttonmiddlemenu_red.png"; - if (log_to_console) { - console.log(" loaded red button design"); - } - break; + imgpathmp3 = "https://sv443.github.io/code/resources/images/buttonleftmp3_red.png"; + imgpathspacer = "https://sv443.github.io/code/resources/images/buttonmiddleraw_red.png"; + imgpathmp4 = "https://sv443.github.io/code/resources/images/buttonrightmp4_red.png"; + imgpathmenu = "https://sv443.github.io/code/resources/images/buttonmiddlemenu_red.png"; + if(log_to_console) { + console.log(" loaded red button design"); + } + break; default: - imgpathmp3 = "https://sv443.github.io/code/resources/images/buttonleftmp3.png"; - imgpathspacer = "https://sv443.github.io/code/resources/images/buttonmiddleraw.png"; - imgpathmp4 = "https://sv443.github.io/code/resources/images/buttonrightmp4.png"; - imgpathmenu = "https://sv443.github.io/code/resources/images/buttonmiddlemenu.png"; - error_content = "incorrect button color value was chosen in the settings - loading default (orange) button color instead"; - if (log_to_console) { - console.log(" incorrect value was chosen in the settings - loading default (orange) button design"); - } - break; - } - if (enable_version_watermark) { - watermarkcontent = 'TamperTubePlus - ' + - 'v' + curversion; - } + imgpathmp3 = "https://sv443.github.io/code/resources/images/buttonleftmp3.png"; + imgpathspacer = "https://sv443.github.io/code/resources/images/buttonmiddleraw.png"; + imgpathmp4 = "https://sv443.github.io/code/resources/images/buttonrightmp4.png"; + imgpathmenu = "https://sv443.github.io/code/resources/images/buttonmiddlemenu.png"; + error_content = "incorrect button color value was chosen in the settings - loading default (orange) button color instead"; + if(log_to_console) { + console.log(" incorrect value was chosen in the settings - loading default (orange) button design"); + } + break; +} +if(enable_version_watermark) { + watermarkcontent = 'TamperTubePlus - ' + + 'v' + curversion; +} - if (enable_ui && disable_polymer_design && !URLpath.includes("embed") && URLpath.includes("watch")) { +if (enable_ui && disable_polymer_design && !URLpath.includes("embed") && URLpath.includes("watch")) { document.addEventListener("DOMContentLoaded", function () { - var dlbuttonelem = document.createElement('div'); - dlbuttonelem.innerHTML = '
' + + var dlbuttonelem = document.createElement('div'); + dlbuttonelem.innerHTML = '
' + '' // concatenation errors can't be fixed + '' + '' // concatenation errors can't be fixed + '' + '' // concatenation errors can't be fixed + '
' + watermarkcontent + '   ' + error_content + '
'; - document.body.appendChild(dlbuttonelem); - document.getElementById("menubtn").addEventListener("click", function () { - openmenu(); - }); - if (log_to_console) { - console.log(" loaded all ui elements for old youtube design"); - } - }); - } - else if (enable_ui && !disable_polymer_design && !URLpath.includes("embed") && URLpath.includes("watch")) { - document.addEventListener("DOMContentLoaded", function () { - window.onload = function () { - var dlbuttonelem = document.createElement('div'); - dlbuttonelem.innerHTML = '
' + - '' // concatenation errors can't be fixed - + '' + - '' // concatenation errors can't be fixed - + '' + - '' // concatenation errors can't be fixed - + watermarkcontent + '   ' + error_content + '
'; document.body.appendChild(dlbuttonelem); document.getElementById("menubtn").addEventListener("click", function () { - openmenu(); + openmenu(); }); - if (log_to_console) { - console.log(" loaded all ui elements for new youtube design"); + if(log_to_console) { + console.log(" loaded all ui elements for old youtube design"); } - } }); - } +} +else if(enable_ui && !disable_polymer_design && !URLpath.includes("embed") && URLpath.includes("watch")) { + document.addEventListener("DOMContentLoaded", function () { + window.onload = function () { + var dlbuttonelem = document.createElement('div'); + dlbuttonelem.innerHTML = '
' + + '' // concatenation errors can't be fixed + + '' + + '' // concatenation errors can't be fixed + + '' + + '' // concatenation errors can't be fixed + + watermarkcontent + '   ' + error_content + '
'; + document.body.appendChild(dlbuttonelem); + document.getElementById("menubtn").addEventListener("click", function () { + openmenu(); + }); + if(log_to_console) { + console.log(" loaded all ui elements for new youtube design"); + } + } + }); +} - var menuelem = document.createElement('div'); - function openmenu() { - if (log_to_console) { - console.log(" triggered the menu"); - } - function testf(){ - alert("yiss"); +var menuelem = document.createElement('div'); +function openmenu() { + if(log_to_console) { + console.log(" triggered the menu"); } + if(disable_polymer_design && !document.body.innerHTML.includes("id='ttp_menu_box'") && closemenu_button_position.includes("left") || closemenu_button_position.includes("right")){ menuelem.align="center"; menuelem.innerHTML="
" @@ -340,7 +376,7 @@ var stylesheet = 0; // switch through stylesheets for YouTube (default: 0) (0: d + " onclick='document.getElementById(" + '"' + "ttp_menu_box" + '"' + ").outerHTML=" + '""'// concatenation errors can't be fixed + ";document.getElementById(" + '"' + "ttp_menu_box" + '"' + ").innerHTML=" + '""' + ";'>"// concatenation errors can't be fixed + "

" - + "

Settings:


" + + "

Settings (Work in Progress):


" + "Language  OUT      " + "Debug  OUT      " + "Watermark  OUT      " @@ -363,10 +399,11 @@ var stylesheet = 0; // switch through stylesheets for YouTube (default: 0) (0: d }); document.getElementById("masthead-positioner").appendChild(menuelem); - document.addEventListener("keyup", function (g) { - if (g.keyCode == closemenu_hotkey) { + document.addEventListener("keyup", function (e) { + if(e.keyCode == closemenu_hotkey) { menuelem.innerHTML=""; menuelem.outerHTML=""; + gettags(); } }); } @@ -376,184 +413,262 @@ var stylesheet = 0; // switch through stylesheets for YouTube (default: 0) (0: d else if(!disable_polymer_design && !document.body.innerHTML.includes("id='ttp_menu_box'")){ alert("gg"); } - } +} + +var taglist; +window.onload = function(){ + if(show_tags_in_description){ + setInterval(function(){ + if(!document.body.innerHTML.includes('id="ttp_taglist"')){ + taglist=""; + gettags(); + } + }, 500); + } +}; + +function gettags(){ + taglist = "

Video Tags:
"; + var metas = document.getElementsByTagName('meta'); + var metanbr = 0; + for(var ii = 0; ii < metas.length; ii++) { + if(metas[ii].getAttribute("property") == "og:video:tag") { + metanbr++; + if(metanbr != 1){ + taglist += ", "; + } + taglist += metas[ii].getAttribute("content"); + var mlm = metas.length - 1; + } + } + taglist += "

Reload Page to show new Tags" + + ""; + var tagcontainer = document.createElement("div"); + tagcontainer.id = "ttp_taglist"; + tagcontainer.innerHTML = "" + taglist + ""; + if(disable_polymer_design == false){ + document.getElementById("watch-description-extras").appendChild(tagcontainer); + } +} - /*Video Downloader Video Downloader Video Downloader*/ +/*Switch /watch and /embed Switch /watch and /embed Switch /watch and /embed*/ - document.addEventListener("keyup", function (f) { - if (f.keyCode == download_hotkey && URLpath.includes("/watch")) { - if (log_to_console) { - console.log(" registered download keystroke: " + download_hotkey); - } - openc2mp3(); +function getwatchid() { + if(window.location.href.includes("/watch")){ + var w1 = window.location.href.split("?"); + var w2 = w1[1].split("&"); + for(var i = 0; i < w2.length; i++){ + if(w2[i].includes("v=")){ + var wd = w2[i].replace("v=",""); + if(log_to_console){console.log(" watch id: " + wd)} + return wd; + } + } } - else if (f.keyCode == download_hotkey && URLpath.includes("/subscribe_embed")) { - if (log_to_console) { - console.log(" registered download keystroke: " + download_hotkey); - } - openc2mp3(); + else if(window.location.href.includes("/embed")){ + var pn = window.location.pathname.split("/"); + if(log_to_console){console.log(" watch id: " + pn[2])} + return pn[2]; } - }); +} - function openc2mp3() { - var dl_format = prompt(lang_dl_format); - if (dl_format == "mp3" || dl_format == "m4a" || dl_format == "aac" || dl_format == "flac" || dl_format == "ogg" || dl_format == "wma" || dl_format == "mp4" || dl_format == "avi" || dl_format == "wmv" || dl_format == "3gp") { - if (log_to_console) { - console.log(" download - entered correct file format: " + dl_format + ", downloading..."); - } - window.open("http://convert2mp3.net/addon_call.php?format=" + dl_format + "&url=" + curURL + queryString); +function parsevideotime() { + var rawvt = document.getElementsByClassName("ytp-time-current")[0].innerHTML; + var vtsp = rawvt.split(":"); + var mins = vtsp[0]; + var secs = vtsp[1]; + if(log_to_console){console.log(" switching /watch and /embed with " + mins + " minutes and " + secs + " seconds");} + if(mins > 0){ + return parseInt(mins) * parseInt(60) + parseInt(secs); } else { - if (dl_format === null || dl_format === "" || dl_format == "null") { - if (log_to_console) { - console.log(" download - cancelled operation"); - } - return null; - } - else if (dl_format == "succ") { - if (log_to_console) { - console.log("SUCC"); - console.log("SUCC"); - console.log("SUCC"); - console.log("SUCC"); - console.log("SUCC"); - console.log("SUCC"); - console.log("SUCC"); - console.log("SUCC"); - console.log("SUCC"); - } - window.open("https://sv443.github.io/code/succ.html"); - } - else { - if (log_to_console) { - console.log(" download - entered wrong file format: " + dl_format); + return secs; + } +} + +document.addEventListener("keydown", function (e) { + if(e.keyCode == player_switch_hotkey){ + pressK(); + if(window.location.href.includes("/watch")){ + setTimeout(function(){window.location.replace("https://www.youtube.com/embed/" + getwatchid() + "?autoplay=1&start=" + parsevideotime());}, 400); } - var confirmretry = confirm(lang_confirm_dl_retry); - if (confirmretry) {} - else { - if (log_to_console) { - console.log(" download - cancelled operation after retrying"); - } + else if(window.location.href.includes("/embed")){ + setTimeout(function(){window.location.replace("https://www.youtube.com/watch?v=" + getwatchid() + "&t=" + parsevideotime() + "s");}, 400); } - } } - } +}); +function pressK() { + var keyEvent = new KeyboardEvent("keypress", {key : "k", char : "k", ctrlKey: false, shiftKey: false}); + document.body.dispatchEvent(keyEvent); +} - /*Quick Search Quick Search Quick Search*/ - - document.addEventListener("keyup", function (g) { - if (g.keyCode == search_hotkey) { - if (log_to_console) { - console.log(" registered search keystroke: " + search_hotkey); - } - var search_string = prompt(lang_enter_search_string); - if (search_string !== null && search_string !== "null" && search_string !== "") { - switch (search_engine == 1) { - case "google": - window.open("https://google.com/search?q=" + search_string); - if (log_to_console) { - console.log(" searched for '" + search_string + "' in google"); - } - break; - case "duckduckgo": - window.open("https://duckduckgo.com/?q=" + search_string); - if (log_to_console) { - console.log(" searched for '" + search_string + "' in duckduckgo"); - } - break; - case "bing": - window.open("https://bing.com/search?q=" + search_string); - if (log_to_console) { - console.log(" searched for '" + search_string + "' in bing"); + +/*Video Downloader Video Downloader Video Downloader*/ + +document.addEventListener("keydown", function (e) { + if(e.keyCode == download_hotkey && URLpath.includes("/watch")) { + if(log_to_console) { + console.log(" registered download keystroke: " + download_hotkey); + } + openc2mp3(); + } + else if(e.keyCode == download_hotkey && URLpath.includes("/subscribe_embed")) { + if(log_to_console) { + console.log(" registered download keystroke: " + download_hotkey); + } + openc2mp3(); + } +}); + +function openc2mp3() { + var dl_format = prompt(lang_dl_format); + if(dl_format == "mp3" || dl_format == "m4a" || dl_format == "aac" || dl_format == "flac" || dl_format == "ogg" || dl_format == "wma" || dl_format == "mp4" || dl_format == "avi" || dl_format == "wmv" || dl_format == "3gp") { + if(log_to_console) { + console.log(" download - entered correct file format: " + dl_format + ", downloading..."); + } + window.open("http://convert2mp3.net/addon_call.php?format=" + dl_format + "&url=" + curURL + queryString); + } + else { + if(dl_format === null || dl_format === "") { + if(log_to_console) { + console.log(" download - cancelled operation"); } - break; - case "yahoo": - window.open("https://search.yahoo.com/search?p=" + search_string); - if (log_to_console) { - console.log(" searched for '" + search_string + "' in yahoo"); + return null; + } + else if (dl_format == "succ") { + window.open("https://sv443.github.io/code/succ.html"); + } + else { + if(log_to_console) { + console.log(" download - entered wrong file format: " + dl_format); } - break; - case "ecosia": - window.open("https://www.ecosia.org/search?q=" + search_string); - if (log_to_console) { - console.log(" searched for '" + search_string + "' in ecosia"); + var confirmretry = confirm(lang_confirm_dl_retry); + if(confirmretry) {} + else { + if(log_to_console) { + console.log(" download - cancelled operation after retrying"); } - break; - case "disabled": - break; - default: - alert("You chose the wrong search engine in the settings!\nOpening Google as a default"); - window.open("https://google.com/search?q=" + search_string); - if (log_to_console) { - console.log(" wrong search engine chosen"); } - break; } - } } - }); +} - /*Start Radio Start Radio Start Radio*/ +/*Quick Search Quick Search Quick Search*/ - var finalmixplhref; - if (disable_polymer_design) { +document.addEventListener("keyup", function (e) { + if(e.keyCode == search_hotkey) { + if(log_to_console) { + console.log(" registered search keystroke: " + search_hotkey); + } + var search_string = prompt(lang_enter_search_string); + if(search_string !== null && search_string !== "null" && search_string !== "") { + switch (search_engine == 1) { + case "google": + window.open("https://google.com/search?q=" + search_string); + if (log_to_console) { + console.log(" searched for '" + search_string + "' in google"); + } + break; + case "duckduckgo": + window.open("https://duckduckgo.com/?q=" + search_string); + if (log_to_console) { + console.log(" searched for '" + search_string + "' in duckduckgo"); + } + break; + case "bing": + window.open("https://bing.com/search?q=" + search_string); + if (log_to_console) { + console.log(" searched for '" + search_string + "' in bing"); + } + break; + case "yahoo": + window.open("https://search.yahoo.com/search?p=" + search_string); + if (log_to_console) { + console.log(" searched for '" + search_string + "' in yahoo"); + } + break; + case "ecosia": + window.open("https://www.ecosia.org/search?q=" + search_string); + if (log_to_console) { + console.log(" searched for '" + search_string + "' in ecosia"); + } + break; + case "disabled": + break; + default: + alert("You chose the wrong search engine in the settings!\nOpening Google as a default"); + window.open("https://google.com/search?q=" + search_string); + if (log_to_console) { + console.log(" wrong search engine chosen"); + } + break; + } + } + } +}); + + +/*Start Radio Start Radio Start Radio*/ + +var finalmixplhref; +if(disable_polymer_design) { finalmixplhref = "not retrieved yet"; document.addEventListener("DOMContentLoaded", function () {if (document.getElementById('eow-title').innerHTML.includes("Avicii") || document.getElementById('eow-title').innerHTML.includes("avicii")) {console.log("RIP Avicii");}}); document.addEventListener("DOMContentLoaded", function () { - var mixpl = document.getElementsByClassName('mix-playlist'); - var mixplhref; - for (var i = 0; i < mixpl.length; i++) { - mixplhref = mixpl[i].href; - } - - if (mixplhref == "undefined" || mixplhref === undefined || mixplhref == "null" || mixplhref === null) { - return; - } - else { - finalmixplhref = mixplhref; - } - if (log_to_console) { - console.log(" href of mixplaylist: " + finalmixplhref); - } - document.addEventListener("keyup", function (h) { - if (h.keyCode == radio_hotkey) { - if (log_to_console) { - console.log(" registered radio keystroke: " + radio_hotkey); - } - if (mixplhref == "undefined" || mixplhref === undefined || mixplhref == "null" || mixplhref === null) { - alert(lang_no_mix_pl); - } - else { - window.location.replace(finalmixplhref); - } - } - }); + var mixpl = document.getElementsByClassName('mix-playlist'); + var mixplhref; + for (var i = 0; i < mixpl.length; i++) { + mixplhref = mixpl[i].href; + } + + if(mixplhref == "undefined" || mixplhref === undefined || mixplhref == "null" || mixplhref === null) { + return; + } + else { + finalmixplhref = mixplhref; + } + if(log_to_console) { + console.log(" href of mixplaylist: " + finalmixplhref); + } + document.addEventListener("keyup", function (e) { + if(e.keyCode == radio_hotkey) { + if(log_to_console) { + console.log(" registered radio keystroke: " + radio_hotkey); + } + if(mixplhref == "undefined" || mixplhref === undefined || mixplhref == "null" || mixplhref === null) { + alert(lang_no_mix_pl); + } + else { + window.location.replace(finalmixplhref); + } + } + }); }); - } - else if (disable_polymer_design === false) { - if (log_to_console) { - console.log(" quick radio mix playlist feature disabled for new design"); +} +else if(disable_polymer_design === false) { + if(log_to_console) { + console.log(" quick radio mix playlist feature disabled for new design!"); } - } +} - /*CSS Stylesheets CSS Stylesheets CSS Stylesheets*/ +/*CSS Stylesheets CSS Stylesheets CSS Stylesheets*/ - if (log_to_console) { +if(log_to_console) { console.log(" applying stylesheet " + stylesheet); - } +} - switch (stylesheet) { +switch (stylesheet) { case 0: - if (log_to_console) { - console.log(" stylesheet was disabled in the settings"); - } - break; + if (log_to_console) { + console.log(" stylesheet was disabled in the settings"); + } + break; case 1: - new GM_addStyle(` + new GM_addStyle(` #eow-title { font-family: "Ubuntu", sans-serif; font-size: 20px; @@ -668,25 +783,30 @@ html .watch-stage-mode video.video-stream.html5-main-video background-color: #616161!important; } `); - break; + break; default: - stylesheet = 0; - error_content = "incorrect stylesheet value was chosen in the settings - disabling stylesheet instead"; - console.log("incorrect value was chosen in the settings - disabling stylesheet"); - break; - } + stylesheet = 0; + error_content = "incorrect stylesheet value was chosen in the settings - disabling stylesheet instead"; + console.log("incorrect value was chosen in the settings - disabling stylesheet"); + break; +} + - /*End End End*/ +/*End End End*/ - if (log_to_console) { +if(log_to_console) { console.log("--END TamperTubePlus"); - } +} })(); /* my temporary dev code storage -save and get values - function GM_setValue(key, value); - function GM_getValue(key, defaultValue); +save and get key's value +GM_setValue(key, value); +GM_getValue(key, defaultValue); +list all keys +GM_listValues(); +delete key and value +GM_deleteValue(key); */