12345678910111213141516171819202122232425262728293031323334353637 |
- // ==UserScript==
- // @name BetterYTM
- // @homepageURL https://github.com/Sv443/BetterYTM#readme
- // @namespace https://github.com/Sv443/BetterYTM
- // @version 1.0.0
- // @description Configurable layout and UX improvements for YouTube Music
- // @description:de Konfigurierbares Layout und UX-Verbesserungen für YouTube Music
- // @license MIT
- // @author Sv443
- // @copyright Sv443 (https://github.com/Sv443)
- // @match https://music.youtube.com/*
- // @match https://www.youtube.com/*
- // @icon https://raw.githubusercontent.com/Sv443/BetterYTM/main/resources/icon/icon.png
- // @run-at document-start
- // @grant GM.getValue
- // @grant GM.setValue
- // @connect self
- // @connect youtube.com
- // @connect github.com
- // @connect githubusercontent.com
- // @downloadURL https://raw.githubusercontent.com/Sv443/BetterYTM/main/dist/BetterYTM.user.js
- // @updateURL https://raw.githubusercontent.com/Sv443/BetterYTM/main/dist/BetterYTM.user.js
- // ==/UserScript==
- /*
- ▄▄▄ ▄ ▄▄▄▄▄▄ ▄
- █ █ ▄▄▄ █ █ ▄▄▄ ▄ ▄█ █ █ █▀▄▀█
- █▀▀▄ █▄█ █▀ █▀ █▄█ █▀ █ █ █ █
- █▄▄▀ ▀▄▄ ▀▄▄ ▀▄▄ ▀▄▄ █ █ █ █ █
- Made with ❤️ by Sv443
- I welcome every contribution on GitHub! */
- /* Disclaimer: I am not affiliated with YouTube, Google, Alphabet, Genius or anyone else */
- /* C&D this 🖕 */
- !function(){"use strict";var e={546:function(e,t){var n=function(){function e(){this._eventHandlers={}}return e.prototype.isValidType=function(e){return"string"==typeof e},e.prototype.isValidHandler=function(e){return"function"==typeof e},e.prototype.on=function(e,t){if(!e||!t)return!1;if(!this.isValidType(e))return!1;if(!this.isValidHandler(t))return!1;var n=this._eventHandlers[e];return n||(n=this._eventHandlers[e]=[]),!(n.indexOf(t)>=0||(t._once=!1,n.push(t),0))},e.prototype.once=function(e,t){if(!e||!t)return!1;if(!this.isValidType(e))return!1;if(!this.isValidHandler(t))return!1;var n=this.on(e,t);return n&&(t._once=!0),n},e.prototype.off=function(e,t){if(!e)return this.offAll();if(t){if(this.isValidType(e)&&this.isValidHandler(t)){var n=this._eventHandlers[e];if(n&&n.length)for(var o=0;o<n.length;o++)if(n[o]===t){n.splice(o,1);break}}}else this._eventHandlers[e]=[]},e.prototype.offAll=function(){this._eventHandlers={}},e.prototype.fire=function(e,t){if(e&&this.isValidType(e)){var n=this._eventHandlers[e];if(n&&n.length)for(var o=this.createEvent(e,t),i=0,r=n;i<r.length;i++){var l=r[i];this.isValidHandler(l)&&(l._once&&(o.once=!0),l(o),o.once&&this.off(e,l))}}},e.prototype.has=function(e,t){if(!e||!this.isValidType(e))return!1;var n=this._eventHandlers[e];return!(!n||!n.length||t&&this.isValidHandler(t)&&!(n.indexOf(t)>=0))},e.prototype.getHandlers=function(e){return e&&this.isValidType(e)&&this._eventHandlers[e]||[]},e.prototype.createEvent=function(e,t,n){return void 0===n&&(n=!1),{type:e,data:t,timestamp:Date.now(),once:n}},e}();t.vp=n,new n}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}!function(){const e=!0,t=50,o=150,i=Object.freeze({name:GM.info.script.name,version:GM.info.script.version,namespace:GM.info.script.namespace,lastCommit:"f0b5e4a"});function r(){const{hostname:e}=new URL(location.href);if(e.includes("music.youtube"))return"ytm";if(e.includes("youtube"))return"yt";throw new Error("BetterYTM is running on an unexpected website. Please don't tamper with the @match directives in the userscript header.")}function l(e,t){var n;return null===(n=e.parentNode)||void 0===n||n.insertBefore(t,e.nextSibling),t}function s(t,n){"string"==typeof n&&0!==n.length||(n=String(Math.floor(1e4*Math.random())));const o=document.createElement("style");o.id=`betterytm-style-${n}`,o.innerHTML=t,document.querySelector("head").appendChild(o),e&&console.log(`BetterYTM: Inserted global style with ref '${n}':`,o)}const a=new(n(546).vp);let c=null;function d(t){var n,o;if(["ArrowLeft","ArrowRight"].includes(t.code)){if(["INPUT","TEXTAREA","SELECT"].includes(null!==(o=null===(n=document.activeElement)||void 0===n?void 0:n.tagName)&&void 0!==o?o:"_"))return e&&console.info(`BetterYTM: Captured valid key but the current active element is <${document.activeElement.tagName.toLowerCase()}>, so the keypress is ignored`);e&&console.log(`BetterYTM: Captured key '${t.code}' in proxy listener`);const i={altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1,target:document.body,currentTarget:document.body,originalTarget:document.body,explicitOriginalTarget:document.body,srcElement:document.body,type:"keydown",bubbles:!0,cancelBubble:!1,cancelable:!0,isTrusted:!0,repeat:!1,view:window};let r=!1,l={};switch(t.code){case"ArrowLeft":l={code:"KeyH",key:"h",keyCode:72,which:72};break;case"ArrowRight":l={code:"KeyL",key:"l",keyCode:76,which:76};break;default:r=!0}if(r)e&&console.warn(`BetterYTM: Captured key '${t.code}' has no defined behavior`);else{const n=Object.assign(Object.assign({code:""},i),l);document.body.dispatchEvent(new KeyboardEvent("keydown",n)),e&&console.log(`BetterYTM: Dispatched proxy keydown event: [${t.code}] -> [${n.code}]`)}}}var u=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function l(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,s)}a((o=o.apply(e,t||[])).next())}))};const y=e?"develop":"main";function m(){const e=document.querySelector("#betterytm-menu-bg");e.style.visibility="hidden",e.style.display="none"}let p;let f=0;function h(){const n=document.querySelector('.ytmusic-nav-bar ytmusic-pivot-bar-item-renderer[tab-id="SPunlimited"]');n?(n.remove(),e&&console.log(`BetterYTM: Removed upgrade tab after ${f} tries`)):f<t?(setTimeout(h,o),f++):console.error(`BetterYTM: Couldn't find upgrade tab to remove after ${f} tries`)}function g(){const{volumeSliderSize:e}=p;"number"!=typeof e||isNaN(Number(e))||s(`.volume-slider.ytmusic-player-bar, .expand-volume-slider.ytmusic-player-bar {\n width: ${e}px !important;\n}`,"vol_slider_size")}function v(){document.querySelector("tp-yt-paper-slider#volume-slider").setAttribute("step",String(p.volumeSliderStep))}function b(e){const t=document.createElement("div");t.className="bytm-queue-btn-container",t.innerText="ayo",e.querySelector(".song-info").appendChild(t),e.classList.add("bytm-has-queue-btns")}var w=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function l(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,s)}a((o=o.apply(e,t||[])).next())}))},x=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(o,i){!function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)}(o,i,(t=e[n](t)).done,t.value)}))}}};const T="https://api.sv443.net/geniurl",k=`${T}/search/top`;let E="",S=0;function C(){return w(this,void 0,void 0,(function*(){const n=document.querySelector(".middle-controls-buttons ytmusic-like-button-renderer#like-button-renderer");if(!n)return S++,S<t?setTimeout(C,o):console.error(`BetterYTM: Couldn't find element to append lyrics buttons to after ${S} tries`);const i=document.querySelector(".content-info-wrapper > yt-formatted-string"),r=yield M(),a=document.createElement("a");a.id="betterytm-lyrics-button",a.className="ytmusic-player-bar",a.title=r?"Click to open this song's lyrics in a new tab":"Loading...",r&&(a.href=r),a.target="_blank",a.rel="noopener noreferrer",a.style.visibility=r?"initial":"hidden",a.style.display=r?"inline-flex":"none",s(" #betterytm-lyrics-button {\n align-items: center;\n justify-content: center;\n position: relative;\n vertical-align: middle;\n\n margin-left: 8px;\n width: 40px;\n height: 40px;\n border-radius: 100%;\n background-color: transparent;\n }\n\n #betterytm-lyrics-button:hover {\n background-color: #383838;\n }\n\n #betterytm-lyrics-img {\n display: inline-block;\n z-index: 10;\n width: 24px;\n height: 24px;\n padding: 5px;\n }","lyrics");const c=document.createElement("img");c.id="betterytm-lyrics-img",c.src="https://raw.githubusercontent.com/Sv443/BetterYTM/main/resources/external/genius.png",a.appendChild(c),e&&console.log(`BetterYTM: Inserted genius button after ${S} tries:`,a),l(n,a),E=i.title,new MutationObserver((t=>{var n,o,i;return w(this,void 0,void 0,(function*(){var r,l,s,a;try{for(n=!0,o=x(t);!(r=(i=yield o.next()).done);){a=i.value,n=!1;try{const t=a.target.title;if(t!=E&&t.length>0){const n=document.querySelector("#betterytm-lyrics-button");if(!n)return;e&&console.log(`BetterYTM: Song title changed from '${E}' to '${t}'`),n.style.cursor="wait",n.style.pointerEvents="none",E=t;const o=yield M();if(!o)continue;n.href=o,n.title="Click to open this song's lyrics in a new tab",n.style.cursor="pointer",n.style.visibility="initial",n.style.display="inline-flex",n.style.pointerEvents="initial"}}finally{n=!0}}}catch(e){l={error:e}}finally{try{n||r||!(s=o.return)||(yield s.call(o))}finally{if(l)throw l.error}}}))})).observe(i,{attributes:!0,attributeFilter:["title"]})}))}function M(){var e,t;return w(this,void 0,void 0,(function*(){try{const n="string"==typeof(null===(e=document.querySelector("ytmusic-player"))||void 0===e?void 0:e.getAttribute("video-mode_")),o=document.querySelector(".content-info-wrapper > yt-formatted-string"),i=document.querySelector("span.subtitle > yt-formatted-string:first-child");if(!o||!i||!o.title)return null;const r=e=>e.replace(/\(.+\)/gim,"").replace(/\[.+\]/gim,"").trim(),l=e=>((e=e.split(/\s*\u2022\s*/gimu)[0]).match(/&/)&&(e=e.split(/\s*&\s*/gm)[0]),e.match(/,/)&&(e=e.split(/,\s*/gm)[0]),e.trim()),s=r(o.title),a=l(i.title),c=()=>w(this,void 0,void 0,(function*(){if(!s.includes("-"))return yield $(a,s);const[e,...t]=s.split("-").map((e=>e.trim()));return yield $(e,t.join(" "))}));return n?yield c():null!==(t=yield $(a,s))&&void 0!==t?t:yield c()}catch(e){return console.error("BetterYTM: Couldn't resolve genius.com URL:",e),null}}))}function $(t,n){return w(this,void 0,void 0,(function*(){try{const o=`${k}?artist=${encodeURIComponent(t)}&song=${encodeURIComponent(n)}`;e&&console.log(`BetterYTM: Requesting URL from geniURL at '${o}'`);const i=yield(yield fetch(o)).json();if(i.error)return void console.error("BetterYTM: Couldn't fetch genius.com URL:",i.message);const r=i.url;return e&&console.info(`BetterYTM: Found genius URL: ${r}`),r}catch(e){return void console.error("BetterYTM: Couldn't get genius URL due to error:",e)}}))}function B(){!function(){var e,t,n,o;e=this,t=void 0,o=function*(){},new((n=void 0)||(n=Promise))((function(i,r){function l(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,s)}a((o=o.apply(e,t||[])).next())}))}(),s('#bytm-menu-header-option {\n display: "flex";\n justify-content: center;\n align-items: center;\n}\n\n#bytm-menu-header-option h3 {\n margin: 0;\n}\n\n.bytm-menu-tab[data-active="true"] {\n display: none;\n}\n\n.bytm-menu-tab[data-active="false"] {\n display: none;\n}\n',"menu2"),document.addEventListener("DOMContentLoaded",(()=>{const e=document.createElement("div");e.id="bytm-menu-backdrop",e.style.display="none",e.innerHTML='<dialog id="bytm-menu-dialog"> <div id="bytm-menu-header"> <div class="bytm-menu-header-option" id="bytm-menu-tab-options-header" data-active="true"> <h3>Options</h3> </div> <div class="bytm-menu-header-option" id="bytm-menu-tab-changelog-header" data-active="false"> <h3>Changelog</h3> </div> </div> <div id="bytm-menu-body"> <div class="bytm-menu-tab-content" id="bytm-menu-tab-options-content" data-active="true"> </div> <div class="bytm-menu-tab-content" id="bytm-menu-tab-changelog-content" data-active="false"> </div> </div> </dialog> '}))}const L=Object.freeze({arrowKeySupport:{desc:"Arrow keys skip forwards and backwards by 10 seconds",type:"toggle",category:"input",default:!0},switchBetweenSites:{desc:"Add F9 as a hotkey to switch between the YT and YTM sites on a video / song",type:"toggle",category:"input",default:!0},switchSitesHotkey:{desc:"Which hotkey needs to be pressed to switch sites?",type:"hotkey",category:"input",default:{key:"F9",shift:!1,ctrl:!1,meta:!1}},anchorImprovements:{desc:"TODO: Make it so middle clicking a song to open it in a new tab is easier",type:"toggle",category:"input",default:!0},removeUpgradeTab:{desc:'Remove the "Upgrade" / YT Music Premium tab',type:"toggle",category:"layout",default:!0},volumeSliderSize:{desc:"The width of the volume slider in pixels",type:"number",category:"layout",min:10,max:1e3,step:5,default:160},volumeSliderStep:{desc:"Volume slider sensitivity - the smaller this number, the finer the volume control",type:"slider",category:"layout",min:1,max:20,default:2},watermarkEnabled:{desc:`Show a ${i.name} watermark under the YTM logo`,type:"toggle",category:"layout",default:!0},queueButtons:{desc:"TODO: Add buttons while hovering over a song in a queue to quickly remove it or open its lyrics",type:"toggle",category:"layout",default:!0},dismissPopup:{desc:'TODO: Automatically dismisses the "are you still there" popup',type:"toggle",category:"layout",default:!0},geniusLyrics:{desc:"Add a button to the media controls to open the current song's lyrics on genius.com in a new tab",type:"toggle",category:"lyrics",default:!0}});var Y=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function l(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,s)}a((o=o.apply(e,t||[])).next())}))};const q=Object.keys(L).reduce(((e,t)=>(e[t]=L[t].default,e)),{});let O;function N(e=!1){return Y(this,void 0,void 0,(function*(){return(void 0===O||e)&&(yield z(O=Object.assign(Object.assign({},q),yield function(){return Y(this,void 0,void 0,(function*(){const e=Object.freeze(Object.assign({},q));try{const t=yield GM.getValue("betterytm-config");return"string"!=typeof t?(yield j(),O=e):Object.freeze(t?JSON.parse(t):{})}catch(t){return yield j(),O=e}}))}()))),O}))}function z(e){if(!e||"object"!=typeof e)throw new TypeError("Feature config not provided or invalid");return O=Object.assign({},e),GM.setValue("betterytm-config",JSON.stringify(e))}function j(){return O=Object.assign({},q),GM.setValue("betterytm-config",JSON.stringify(q))}var R=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function l(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,s)}a((o=o.apply(e,t||[])).next())}))};function _(){return R(this,void 0,void 0,(function*(){const t=yield N(),n=r();e&&console.log(`BetterYTM: Initializing features for domain '${n}'`);try{if("ytm"===n&&(function(){const t=new MutationObserver((([{addedNodes:t,removedNodes:n,target:o}])=>{(t.length>0||n.length>0)&&(e&&console.info("BetterYTM: Detected queue change - added nodes:",t.length,"- removed nodes:",n.length),a.fire("queueChanged",o))}));t.observe(document.querySelector(".side-panel.modular #contents.ytmusic-player-queue"),{childList:!0}),e&&console.info("BetterYTM: Successfully initialized SiteEvents observers"),c=[t]}(),t.arrowKeySupport&&(document.addEventListener("keydown",d),e&&console.log("BetterYTM: Added key press listener")),t.removeUpgradeTab&&h(),t.watermarkEnabled&&function(){const t=document.createElement("span");t.id="betterytm-watermark",t.className="style-scope ytmusic-nav-bar",t.innerText=i.name,t.title="Open menu",t.addEventListener("click",(()=>function(){const e=document.querySelector("#betterytm-menu-bg");e.style.visibility="visible",e.style.display="block"}())),s("#betterytm-watermark {\n font-size: 10px;\n display: inline-block;\n position: absolute;\n left: 45px;\n top: 46px;\n z-index: 10;\n color: white;\n text-decoration: none;\n cursor: pointer;\n}\n\n@media(max-width: 615px) {\n #betterytm-watermark {\n display: none;\n }\n}\n\n#betterytm-watermark:hover {\n text-decoration: underline;\n}","watermark"),l(document.querySelector("#left-content"),t),e&&console.log("BetterYTM: Added watermark element:",t)}(),t.geniusLyrics&&C(),t.queueButtons&&function(){a.on("queueChanged",(e=>{for(const t of e.data.childNodes)t.classList.contains("bytm-has-queue-btns")||b(t)})),s(".side-panel.modular ytmusic-player-queue-item .song-info.ytmusic-player-queue-item {\n position: relative;\n}\n.side-panel.modular ytmusic-player-queue-item .song-info .bytm-queue-btn-container {\n display: none;\n position: absolute;\n right: 0;\n}\n.side-panel.modular ytmusic-player-queue-item:hover .song-info .bytm-queue-btn-container {\n display: inline-block;\n}","queue-btns");const e=document.querySelectorAll("#contents.ytmusic-player-queue > ytmusic-player-queue-item");0!==e.length&&e.forEach((e=>b(e)))}(),"number"==typeof t.volumeSliderSize&&g(),t.anchorImprovements,v()),["ytm","yt"].includes(n)){t.switchBetweenSites&&function(t){document.addEventListener("keydown",(n=>{"F9"==n.key&&function(t){var n;try{let o;if("ytm"===t?o="music":"yt"===t&&(o="www"),!o)throw new TypeError(`Unrecognized domain '${t}'`);const{pathname:i,search:l,hash:s}=new URL(location.href),a=null!==(n=function(e=!1){const t=r();try{if("ytm"===t){const e=document.querySelector("#progress-bar");return isNaN(Number(e.value))?null:Number(e.value)}return null}catch(e){return console.error("BetterYTM: Couldn't get video time due to error:",e),null}}())&&void 0!==n?n:0;e&&console.log(`BetterYTM: Found video time of ${a} seconds`);const c=`https://${o}.youtube.com${i}${l.includes("?")?`${l}&t=${a}`:`?t=${a}`}${s}`;console.info(`BetterYTM - switching to domain '${t}' at ${c}`),location.href=c}catch(e){console.error("BetterYTM: Error while switching site:",e)}}("yt"===t?"ytm":"yt")})),e&&console.log("BetterYTM: Initialized site switch listener")}(n);try{!function(){var t;u(this,void 0,void 0,(function*(){const n=document.createElement("div");n.id="betterytm-menu-bg",n.title="Click here to close the menu",n.style.visibility="hidden",n.style.display="none",n.addEventListener("click",(e=>{"betterytm-menu-bg"===e.target.id&&m()}));const o=document.createElement("div");o.title="",o.id="betterytm-menu",o.style.borderRadius="15px",o.style.display="flex",o.style.flexDirection="column",o.style.justifyContent="space-between";const r=document.createElement("div");r.style.padding="8px 20px 15px 8px",r.style.display="flex",r.style.justifyContent="space-between",r.id="betterytm-menu-titlecont";const l=document.createElement("h2");l.id="betterytm-menu-title",l.innerText=`${i.name} - Configuration`;const a=document.createElement("div");a.id="betterytm-menu-linkscont";const c=(e,t,n)=>{const o=document.createElement("a");o.className="betterytm-menu-link",o.rel="noopener noreferrer",o.target="_blank",o.href=t,o.title=n,o.style.marginLeft="10px";const i=document.createElement("img");i.className="betterytm-menu-img",i.src=e,i.style.width="32px",i.style.height="32px",o.appendChild(i),a.appendChild(o)};c(`https://raw.githubusercontent.com/Sv443/BetterYTM/${y}/resources/external/github.png`,i.namespace,`${i.name} on GitHub`),c(`https://raw.githubusercontent.com/Sv443/BetterYTM/${y}/resources/external/greasyfork.png`,"https://greasyfork.org/xyz",`${i.name} on GreasyFork`);const d=document.createElement("img");d.id="betterytm-menu-close",d.src=`https://raw.githubusercontent.com/Sv443/BetterYTM/${y}/resources/icon/close.png`,d.title="Click to close the menu",d.style.marginLeft="50px",d.style.width="32px",d.style.height="32px",d.addEventListener("click",m),a.appendChild(d),r.appendChild(l),r.appendChild(a);const p=document.createElement("div");p.id="betterytm-menu-opts",p.style.display="flex",p.style.flexDirection="column";const f=(t,n,o)=>u(this,void 0,void 0,(function*(){const i=e=>"object"==typeof e?JSON.stringify(e):String(e);e&&console.info(`BetterYTM: Feature config changed, key '${t}' from value '${i(n)}' to '${i(o)}'`);const r=Object.assign({},yield N());r[t]=o,yield z(r),e&&console.log("BetterYTM: Saved feature config changes:\n",yield GM.getValue("betterytm-config"))})),h=yield N(),g=Object.keys(h);for(const e of g){const n=L[e];if(!n)continue;const{desc:o,type:i,default:r}=n,l=null!==(t=null==n?void 0:n.step)&&void 0!==t?t:void 0,s=h[e]||r||void 0,a=document.createElement("div");a.id=`betterytm-ftconf-${e}`,a.style.display="flex",a.style.flexDirection="row",a.style.justifyContent="space-between",a.style.padding="8px 20px";{const e=document.createElement("span");e.style.display="inline-block",e.style.fontSize="15px",e.innerText=o,a.appendChild(e)}{let t="text";switch(i){case"toggle":t="checkbox";break;case"slider":t="range";break;case"number":t="number"}const o=`betterytm-ftconf-${e}-input`,c=document.createElement("span");c.style.display="inline-block",c.style.whiteSpace="nowrap";const d=document.createElement("input");d.id=o,d.style.marginRight="37px",d.type=t,"toggle"===i&&(d.style.marginLeft="5px"),void 0!==s&&(d.value=String(s)),"number"===i&&l&&(d.step=l),n.min&&n.max&&(d.min=n.min,d.max=n.max),"toggle"===i&&void 0!==s&&(d.checked=Boolean(s));const u=e=>String(e),y=e=>e?"On":"Off";let m;"slider"===i?(m=document.createElement("label"),m.classList.add("betterytm-ftconf-label"),m.style.marginRight="20px",m.style.fontSize="16px",m.htmlFor=o,m.innerText=u(s),d.addEventListener("input",(()=>{m&&(m.innerText=u(parseInt(d.value)))}))):"toggle"===i&&void 0!==s&&(m=document.createElement("label"),m.classList.add("betterytm-ftconf-label"),m.style.paddingLeft="10px",m.style.paddingRight="5px",m.style.fontSize="16px",m.htmlFor=o,m.innerText=y(Boolean(s)),d.addEventListener("input",(()=>{m&&(m.innerText=y(d.checked))}))),d.addEventListener("input",(({currentTarget:t})=>{const n=t;let o=parseInt(n.value);isNaN(o)&&(o=Number(n.value)),void 0!==s&&f(e,s,"toggle"!==i?o:n.checked)}));const p=document.createElement("button");p.innerText="Reset",p.addEventListener("click",(()=>{d["toggle"!==i?"value":"checked"]=r,m&&(m.innerText="toggle"===i?y(d.checked):u(parseInt(d.value))),void 0!==s&&f(e,s,r)})),m&&c.appendChild(m),c.appendChild(d),c.appendChild(p),a.appendChild(c)}p.appendChild(a)}const v=document.createElement("div");v.style.marginTop="20px",v.style.fontSize="17px",v.style.textDecoration="underline",v.style.padding="8px 20px",v.innerText="You need to reload the page to apply changes.";const b=document.createElement("button");b.style.marginLeft="20px",b.innerText="Reload now",b.title="Click to reload the page",b.addEventListener("click",(()=>location.reload())),v.appendChild(b),p.appendChild(v);const w=document.createElement("div");w.id="betterytm-menu-body",w.appendChild(r),w.appendChild(p);const x=document.createElement("div");x.style.display="flex",x.style.justifyContent="space-around",x.style.fontSize="1.15em",x.style.marginTop="10px",x.style.marginBottom="5px";const T=document.createElement("span");T.id="betterytm-menu-version",T.innerText=`v${i.version}`,x.appendChild(T),p.appendChild(x),o.appendChild(w),o.appendChild(x),n.appendChild(o),document.body.appendChild(n),e&&console.log("BetterYTM: Added menu elem:",n),s('#betterytm-menu-bg {\n display: block;\n position: fixed;\n width: 100vw;\n height: 100vh;\n top: 0;\n left: 0;\n z-index: 15;\n background-color: rgba(0, 0, 0, 0.6);\n}\n\n/* TODO:FIXME: needs better positioning (vw and vh === "big no no") */\n#betterytm-menu {\n display: inline-block;\n position: fixed;\n width: 50vw;\n height: auto;\n min-height: 500px;\n left: 25vw;\n top: 25vh;\n z-index: 16;\n overflow: auto;\n padding: 8px;\n color: #fff;\n background-color: #212121;\n}\n\n#betterytm-menu-titlecont {\n display: flex;\n}\n\n#betterytm-menu-title {\n font-size: 20px;\n margin-top: 5px;\n margin-bottom: 8px;\n}\n\n#betterytm-menu-linkscont {\n display: flex;\n}\n\n.betterytm-menu-link {\n display: inline-block;\n}\n\n/*.betterytm-menu-img {\n\n}*/\n\n#betterytm-menu-close {\n cursor: pointer;\n}\n\n.betterytm-ftconf-label {\n user-select: none;\n}',"menu")}))}()}catch(e){console.error("BetterYTM: Couldn't add menu:",e)}}}catch(e){console.error("BetterYTM: General error while executing feature:",e)}}))}!function(){R(this,void 0,void 0,(function*(){yield function(){return e=this,t=void 0,o=function*(){p=yield N()},new((n=void 0)||(n=Promise))((function(i,r){function l(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,s)}a((o=o.apply(e,t||[])).next())}));var e,t,n,o}();try{console.log(`${i.name} v${i.version} (${i.lastCommit}) - ${i.namespace}`),console.log(`Powered by lots of ambition and my song metadata API: ${T}`),document.addEventListener("DOMContentLoaded",_)}catch(e){console.error("BetterYTM - General Error:",e)}try{B()}catch(e){console.error("BetterYTM: Couldn't initialize menu:",e)}}))}()}()}();
- //# sourceMappingURL=BetterYTM.user.js.map
|