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(){var e=n(546);const t=!0,o=Object.freeze({name:GM.info.script.name,version:GM.info.script.version,namespace:GM.info.script.namespace});function i(){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 r(e,t){var n;return null===(n=e.parentNode)||void 0===n||n.insertBefore(t,e.nextSibling),t}function l(e,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=e,document.querySelector("head").appendChild(o),t&&console.log(`BetterYTM: Inserted global style with ref '${n}':`,o)}const s=new e.vp;let c=null;function a(e){var n,o;if(["ArrowLeft","ArrowRight"].includes(e.code)){if(["INPUT","TEXTAREA","SELECT"].includes(null!==(o=null===(n=document.activeElement)||void 0===n?void 0:n.tagName)&&void 0!==o?o:"_"))return t&&console.info(`BetterYTM: Captured valid key but the current active element is <${document.activeElement.tagName.toLowerCase()}>, so the keypress is ignored`);t&&console.log(`BetterYTM: Captured key '${e.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};let r=!1,l={};switch(e.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)t&&console.warn(`BetterYTM: Captured key '${e.code}' has no defined behavior`);else{const n=Object.assign(Object.assign({code:""},i),l);document.body.dispatchEvent(new KeyboardEvent("keydown",n)),t&&console.log(`BetterYTM: Dispatched proxy keydown event: [${e.code}] -> [${n.code}]`)}}}var d=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function l(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,s)}c((o=o.apply(e,t||[])).next())}))};const u=t?"develop":"main";function y(){const e=document.querySelector("#betterytm-menu-bg");e.style.visibility="hidden",e.style.display="none"}let m;function p(){return e=this,t=void 0,o=function*(){m=yield q()},new((n=void 0)||(n=Promise))((function(i,r){function l(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,s)}c((o=o.apply(e,t||[])).next())}));var e,t,n,o}let f=0;function h(){const e=document.querySelector('.ytmusic-nav-bar ytmusic-pivot-bar-item-renderer[tab-id="SPunlimited"]');e?(e.remove(),t&&console.log(`BetterYTM: Removed upgrade tab after ${f} tries`)):f<50?(setTimeout(h,150),f++):console.error(`BetterYTM: Couldn't find upgrade tab to remove after ${f} tries`)}function g(){const{volumeSliderSize:e}=m;"number"!=typeof e||isNaN(Number(e))||l(`.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(m.volumeSliderStep))}function b(e){console.log("Add queue btns:",e);const t=document.createElement("div");t.className="bytm-queue-btn-container",t.innerText="ayo",e.querySelector(".song-info").appendChild(t)}var w=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function l(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,s)}c((o=o.apply(e,t||[])).next())}))};const x="https://api.sv443.net/geniurl",T=`${x}/search/top`;let k="",S=0;function E(){return w(this,void 0,void 0,(function*(){const e=document.querySelector(".middle-controls-buttons ytmusic-like-button-renderer#like-button-renderer");if(!e)return S++,S<50?setTimeout(E,150):console.error(`BetterYTM: Couldn't find element to append lyrics buttons to after ${S} tries`);const n=document.querySelector(".content-info-wrapper > yt-formatted-string"),o=yield M(),i=document.createElement("a");i.id="betterytm-lyrics-button",i.className="ytmusic-player-bar",i.title=o?"Click to open this song's lyrics in a new tab":"Loading...",o&&(i.href=o),i.target="_blank",i.rel="noopener noreferrer",i.style.visibility=o?"initial":"hidden",i.style.display=o?"inline-flex":"none",l(" #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 s=document.createElement("img");s.id="betterytm-lyrics-img",s.src="https://raw.githubusercontent.com/Sv443/BetterYTM/main/resources/external/genius.png",i.appendChild(s),t&&console.log(`BetterYTM: Inserted genius button after ${S} tries:`,i),r(e,i),k=n.title,new MutationObserver((e=>{var n,o,i;return w(this,void 0,void 0,(function*(){var r,l,s,c;try{for(n=!0,o=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)}))}}}(e);!(r=(i=yield o.next()).done);){c=i.value,n=!1;try{const e=c.target.title;if(e!=k&&e.length>0){const n=document.querySelector("#betterytm-lyrics-button");if(!n)return;t&&console.log(`BetterYTM: Song title changed from '${k}' to '${e}'`),n.style.cursor="wait",n.style.pointerEvents="none",k=e;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(n,{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),c=l(i.title),a=()=>w(this,void 0,void 0,(function*(){if(!s.includes("-"))return yield C(c,s);const[e,...t]=s.split("-").map((e=>e.trim()));return yield C(e,t.join(" "))}));return n?yield a():null!==(t=yield C(c,s))&&void 0!==t?t:yield a()}catch(e){return console.error("BetterYTM: Couldn't resolve genius.com URL:",e),null}}))}function C(e,n){return w(this,void 0,void 0,(function*(){try{const o=`${T}?artist=${encodeURIComponent(e)}&song=${encodeURIComponent(n)}`;t&&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 t&&console.info(`BetterYTM: Found genius URL: ${r}`),r}catch(e){return void console.error("BetterYTM: Couldn't get genius URL due to error:",e)}}))}const $={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}},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 BetterYTM watermark under the YTM logo",type:"toggle",category:"layout",default:!0},anchorAroundThumbnail:{desc:"TODO: Make it so middle clicking a song to open in a new tab is easier",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 B=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function l(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,s)}c((o=o.apply(e,t||[])).next())}))};const Y=Object.keys($).reduce(((e,t)=>(e[t]=$[t].default,e)),{});let L;function q(e=!1){return B(this,void 0,void 0,(function*(){let t;if(void 0===L||e){const e=yield function(){return B(this,void 0,void 0,(function*(){const e=Object.freeze(Object.assign({},Y));try{const t=yield GM.getValue("betterytm-config");return"string"!=typeof t?(yield z(),L=e):Object.freeze(t?JSON.parse(t):{})}catch(t){return yield z(),L=e}}))}();L=t=Object.assign(Object.assign({},Y),e),yield O(t)}return L}))}function O(e){if(!e||"object"!=typeof e)throw new TypeError("Feature config not provided or invalid");return GM.setValue("betterytm-config",JSON.stringify(e))}function z(){return GM.setValue("betterytm-config",JSON.stringify(Y))}var R=function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function l(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,s)}c((o=o.apply(e,t||[])).next())}))};R(void 0,void 0,void 0,(function*(){const e=yield q();yield p();try{console.log(`${o.name} v${o.version} - ${o.namespace}`),console.log(`Powered by lots of ambition and my song metadata API called geniURL: ${x}`),document.addEventListener("DOMContentLoaded",(function(){return R(this,void 0,void 0,(function*(){const n=i();t&&console.log(`BetterYTM: Initializing features for domain '${n}'`),function(){const e=new MutationObserver((([e])=>{(e.addedNodes.length>0||e.removedNodes.length>0)&&s.fire("queueChanged",e.target)}));e.observe(document.querySelector(".side-panel.modular #contents.ytmusic-player-queue"),{childList:!0}),c=[e]}();try{if("ytm"===n&&(e.arrowKeySupport&&(document.addEventListener("keydown",a),t&&console.log("BetterYTM: Added key press listener")),e.removeUpgradeTab&&h(),e.watermarkEnabled&&function(){const e=document.createElement("span");e.id="betterytm-watermark",e.className="style-scope ytmusic-nav-bar",e.innerText=o.name,e.title="Open menu",e.addEventListener("click",(()=>function(){const e=document.querySelector("#betterytm-menu-bg");e.style.visibility="visible",e.style.display="block"}())),l("#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"),r(document.querySelector("#left-content"),e),t&&console.log("BetterYTM: Added watermark element:",e)}(),e.geniusLyrics&&E(),e.queueButtons&&function(){s.on("queueChanged",(e=>{for(const t of e.data.childNodes)t.dataset["bytm-has-queue-btns"]||b(t)})),l(".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 e.volumeSliderSize&&g(),v()),["ytm","yt"].includes(n)){e.switchBetweenSites&&function(e){document.addEventListener("keydown",(n=>{"F9"==n.key&&function(e){var n;try{let o;if("ytm"===e?o="music":"yt"===e&&(o="www"),!o)throw new TypeError(`Unrecognized domain '${e}'`);const{pathname:r,search:l,hash:s}=new URL(location.href),c=null!==(n=function(){var e;const t=i();try{return"ytm"===t?null!==(e=document.querySelector("#progress-bar").value)&&void 0!==e?e:null:"yt"===t?0:null}catch(e){return console.error("BetterYTM: Couldn't get video time due to error:",e),null}}())&&void 0!==n?n:0;t&&console.log(`BetterYTM: Found video time of ${c} seconds`);const a=`https://${o}.youtube.com${r}${l.includes("?")?`${l}&t=${c}`:`?t=${c}`}${s}`;console.info(`BetterYTM - switching to domain '${e}' at ${a}`),location.href=a}catch(e){console.error("BetterYTM: Error while switching site:",e)}}("yt"===e?"ytm":"yt")})),t&&console.log("BetterYTM: Initialized site switch listener")}(n);try{!function(){var e;d(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&&y()}));const i=document.createElement("div");i.title="",i.id="betterytm-menu",i.style.borderRadius="15px",i.style.display="flex",i.style.flexDirection="column",i.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 s=document.createElement("h2");s.id="betterytm-menu-title",s.innerText="BetterYTM - Configuration";const c=document.createElement("div");c.id="betterytm-menu-linkscont";const a=(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),c.appendChild(o)};a(`https://raw.githubusercontent.com/Sv443/BetterYTM/${u}/resources/external/github.png`,o.namespace,`${o.name} on GitHub`),a(`https://raw.githubusercontent.com/Sv443/BetterYTM/${u}/resources/external/greasyfork.png`,"https://greasyfork.org/xyz",`${o.name} on GreasyFork`);const m=document.createElement("img");m.id="betterytm-menu-close",m.src=`https://raw.githubusercontent.com/Sv443/BetterYTM/${u}/resources/icon/close.png`,m.title="Click to close the menu",m.style.marginLeft="50px",m.style.width="32px",m.style.height="32px",m.addEventListener("click",y),c.appendChild(m),r.appendChild(s),r.appendChild(c);const p=document.createElement("div");p.id="betterytm-menu-opts",p.style.display="flex",p.style.flexDirection="column";const f=(e,n,o)=>d(this,void 0,void 0,(function*(){const i=e=>"object"==typeof e?JSON.stringify(e):String(e);t&&console.info(`BetterYTM: Feature config changed, key '${e}' from value '${i(n)}' to '${i(o)}'`);const r=Object.assign({},yield q());r[e]=o,yield O(r),t&&console.log("BetterYTM: Saved feature config changes:\n",yield GM.getValue("betterytm-config"))})),h=yield q(),g=Object.keys(h);for(const t of g){const n=$[t];if(!n)continue;const{desc:o,type:i,default:r}=n,l=null!==(e=null==n?void 0:n.step)&&void 0!==e?e:void 0,s=h[t]||r||void 0,c=document.createElement("div");c.id=`betterytm-ftconf-${t}`,c.style.display="flex",c.style.flexDirection="row",c.style.justifyContent="space-between",c.style.padding="8px 20px";{const e=document.createElement("span");e.style.display="inline-block",e.style.fontSize="15px",e.innerText=o,c.appendChild(e)}{let e="text";switch(i){case"toggle":e="checkbox";break;case"slider":e="range";break;case"number":e="number"}const o=`betterytm-ftconf-${t}-input`,a=document.createElement("span");a.style.display="inline-block",a.style.whiteSpace="nowrap";const d=document.createElement("input");d.id=o,d.style.marginRight="37px",d.type=e,"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:e})=>{const n=e;let o=parseInt(n.value);isNaN(o)&&(o=Number(n.value)),void 0!==s&&f(t,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(t,s,r)})),m&&a.appendChild(m),a.appendChild(d),a.appendChild(p),c.appendChild(a)}p.appendChild(c)}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${o.version}`,x.appendChild(T),p.appendChild(x),i.appendChild(w),i.appendChild(x),n.appendChild(i),document.body.appendChild(n),t&&console.log("BetterYTM: Added menu elem:",n),l('#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)}}))}))}catch(e){console.error("BetterYTM - General Error:",e)}yield function(){return e=this,t=void 0,o=function*(){},new((n=void 0)||(n=Promise))((function(i,r){function l(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,s)}c((o=o.apply(e,t||[])).next())}));var e,t,n,o}();try{l('.bytm-menu-tab[data-enabled="false"] {\n display: none;\n}',"menu2")}catch(e){console.error("BetterYTM: Couldn't initialize menu:",e)}}))}()}();
- //# sourceMappingURL=BetterYTM.user.js.map
|