hide twitch sidebar
当前为
// ==UserScript==
// @name Hide Twitch SideBar
// @version 1.7.0
// @description hide twitch sidebar
// @author raianwz
// @match https://www.twitch.tv/*
// @exclude *://*.twitch.tv/moderator/*
// @exclude *://*.twitch.tv/popout/*
// @exclude *://*.twitch.tv/embed/*
// @exclude *://*.twitch.tv/subs/*
// @exclude https://player.twitch.tv/*
// @run-at document-end
// @namespace https://greasyfork.org/users/425245
// ==/UserScript==
let getElement = (e) => document.querySelector(e);
CheckBar();
function CheckBar(){if(!getElement('#btnSideBar')){setTimeout(()=>{LoadBar();CheckBar();},5*1000)}};
function LoadBar(){
const navSidebar = getElement(`[data-a-target="side-nav-bar-collapsed"]`)
navSidebar.style.display="block"
esconder(navSidebar)
function esconder(navSidebar){
let where = getElement('div.Layout-sc-nxg1ff-0.jZAMtK')
const arrow = `<div class="Layout-sc-nxg1ff-0 jA-dUUY"><div class="Layout-sc-nxg1ff-0 dDnLci"><div class="InjectLayout-sc-588ddc-0 collapse-toggle dGPIxK">
<button id="btnSideBar" class="ScCoreButton-sc-1qn4ixc-0 jGqsfG ScButtonIcon-sc-o7ndmn-0 fNzXyu"><div class="ScButtonIconFigure-sc-o7ndmn-1 fppMur"><div class="ScIconLayout-sc-1bgeryd-0 kbOjdP tw-icon">
<div class="ScAspectRatio-sc-1sw3lwy-1 bneAWp tw-aspect"><div class="ScAspectSpacer-sc-1sw3lwy-0 gMCXS"></div><svg width="100%" height="100%" version="1.1" viewBox="0 0 20 20" x="0px" y="0px" class="ScIconSVG-sc-1bgeryd-1 eOJUoR">
<g id="pSeta"><path d="M16 16V4h2v12h-2zM6 9l2.501-2.5-1.5-1.5-5 5 5 5 1.5-1.5-2.5-2.5h8V9H6z"></path></g></svg></div></div></div></button></div></div></div>`;
where.insertAdjacentHTML("beforeBegin",`${arrow}`)
getElement('#btnSideBar').addEventListener("click", function (call){changeSide(navSidebar)})
}
function changeSide(navSidebar){
let pSeta = document.querySelector('#pSeta')
let sideR = `<path d="M4 16V4H2v12h2zM13 15l-1.5-1.5L14 11H6V9h8l-2.5-2.5L13 5l5 5-5 5z">`
let sideL = `<path d="M16 16V4h2v12h-2zM6 9l2.501-2.5-1.5-1.5-5 5 5 5 1.5-1.5-2.5-2.5h8V9H6z">`
if(navSidebar.style.display == "none"){navSidebar.style.display = "block" ; pSeta.innerHTML = `${sideL}`}
else {navSidebar.style.display = "none" ; pSeta.innerHTML = `${sideR}`}
}
}
console.log('Hide Twitch SideBar is enabled')