Skip to content

Commit

Permalink
style: prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 committed Nov 7, 2023
1 parent da80198 commit ab46d1f
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// ==UserScript==
// @name Discord Toggle Sidebar
// @namespace https://github.com/scarf005
// @homepage https://gist.github.com/scarf005/5849921063d34744fde3494abd5ea107
// @updateURL https://gist.githubusercontent.com/scarf005/5849921063d34744fde3494abd5ea107/raw/toggle_sidebar.user.js
// @downloadURL https://gist.githubusercontent.com/scarf005/5849921063d34744fde3494abd5ea107/raw/toggle_sidebar.user.js
// @version 0.5.0
// @description Toggles Discord sidebar
// @author scarf
// @license MIT
// @match https://discord.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=discord.com
// @grant GM_registerMenuCommand
// @run-at document-idle
// @require https://cdn.jsdelivr.net/npm/@violentmonkey/shortcut@1
// ==/UserScript==

{
"use strict"
const { register } = VM.shortcut

/** @param {TemplateStringsArray} texts */
const css = ([text]) => {
const sheet = new CSSStyleSheet()
sheet.replaceSync(text)
return sheet
}

const servers = css`nav[aria-label="서버 사이드바"] { display: none; }`
const channels = css`div[class^="sidebar"] { display: none; }`
const members = css`div[class^=container_]:has(> aside > div > [aria-label="멤버"]) { display: none; }`
const header = css`section[aria-label="채널 헤더"] { display: none; }`

/** @param {CSSStyleSheet} style */
const toggleStyle = (style) => () => style.disabled = !style.disabled

/** @param {{ name: string, sheet: CSSStyleSheet, shortcut: string }} */
const menu = ({ name, sheet, shortcut }) => {
const fn = toggleStyle(sheet)
document.adoptedStyleSheets.push(sheet)
GM_registerMenuCommand(name, fn)
register(shortcut, fn)
}

menu({ name: "서버 토글", shortcut: "c-1", sheet: servers })
menu({ name: "채널 토글", shortcut: "c-2", sheet: channels })
menu({ name: "멤버 토글", shortcut: "c-3", sheet: members })
menu({ name: "헤더 토글", shortcut: "c-4", sheet: header })
}

0 comments on commit ab46d1f

Please sign in to comment.