Last active
March 18, 2021 05:56
-
-
Save s-zeid/263dcd1b6f8470af3e6dc377938e6c89 to your computer and use it in GitHub Desktop.
Custom CSS for Wikimedia sites
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* ==UserStyle== | |
| @name Wikimedia - Custom colors | |
| @namespace https://ns.bnay.me/wikimedia/custom-colors | |
| @version 1.0.0 | |
| @var text u-accent "Accent color" var(--) | |
| @var text u-link "Link color" var(--) | |
| @var text u-link-external "External link color" var(--) | |
| @var text u-link-interwiki "Interwiki link color" var(--) | |
| @var text u-link-new "New page link color" var(--) | |
| ==/UserStyle== */ | |
| /* NOTE: inner @media at-rule intentionally not indented */ | |
| @-moz-document regexp("^https:\\/\\/(([^.-]{2,3}(-[^.]+)?|commons|incubator|meta|outreach|simple|species|wiki(mania|tech))\\.(wiki(pedia|news|voyage|quote|versity|source|books|media)|wiktionary)|www\\.(mediawiki|wikidata)|wikisource)\\.org\\/.*") { | |
| @media screen { | |
| :root { | |
| --x-accent: var(--u-accent, #a02); | |
| --x-link: var(--u-link, #a02); | |
| --x-link-external: var(--u-link-external, #75a); /* #36b; */ | |
| --x-link-interwiki: var(--u-link-interwiki, #b42); | |
| --x-link-new: var(--u-link-new, #666); | |
| } | |
| :focus { | |
| outline-color: var(--x-accent); | |
| } | |
| a { | |
| text-decoration: none; | |
| } | |
| a:hover { | |
| text-decoration: underline; | |
| } | |
| a, a:hover, a:visited, | |
| .toctogglelabel, | |
| .vector-menu-portal .body li a, | |
| .vector-menu-portal .body li a:visited, | |
| .vector-menu-portal .vector-menu-content li a, | |
| .vector-menu-portal .vector-menu-content li a:visited, | |
| .vector-menu-dropdown li a, | |
| .vector-menu-dropdown li a:visited, | |
| .vector-menu-tabs li a, | |
| .vector-menu-tabs li a:visited, | |
| .wikiEditor-ui-toolbar .tabs span.tab a { | |
| color: var(--x-link); | |
| } | |
| a.mw-selflink:hover { | |
| color: inherit; | |
| text-decoration: inherit; | |
| } | |
| .mw-parser-output a.external, .mw-parser-output a.external:hover, .mw-parser-output a.external:visited { | |
| color: var(--x-link-external); | |
| } | |
| .mw-parser-output .external { | |
| background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0,0 12,12' width='12' height='12' color='%23808080' fill='currentColor' stroke='currentColor'><path d='M5,3.5 h-3.5 v7 h7 v-3.5' fill='none' /><path d='M4,8 l6,-6 Z M6.25,1.5 h4.25 v4.25 l-1.5,-3 Z' /></svg>"); | |
| } | |
| .mw-content-rtl .mw-parser-output .external { | |
| background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0,0 12,12' width='12' height='12' color='%23808080' fill='currentColor' stroke='currentColor'><path d='M7,3.5 h3.5 v7 h-7 v-3.5' fill='none' /><path d='M8,8 l-6,-6 Z M5.75,1.5 h-4.25 v4.25 l1.5,-3 Z' /></svg>"); | |
| } | |
| .mw-parser-output a.extiw, .mw-parser-output a.extiw:hover, .mw-parser-output a.extiw:visited { | |
| color: var(--x-link-interwiki); | |
| } | |
| a.new, .new a, a.new:hover, .new a:hover, a.new:visited, .new a:visited, | |
| #p-personal a.new, | |
| .vector-menu-tabs .new a, .vector-menu-tabs .new a:visited { | |
| color: var(--x-link-new); | |
| } | |
| .mw-ui-input:focus { | |
| border-color: var(--x-accent); | |
| box-shadow: inset 0 0 0 1px var(--x-accent); | |
| } | |
| #mw-sidebar-button:hover { | |
| background-color: rgba(36, 36, 36, .028); | |
| } | |
| #mw-sidebar-button:focus { | |
| border-color: var(--x-accent); | |
| outline-color: var(--x-accent); | |
| box-shadow: inset 0 0 0 1px var(--x-accent); | |
| } | |
| #searchInput:focus, #simpleSearch:hover #searchInput:focus { | |
| border-color: var(--x-accent); | |
| box-shadow: inset 0 0 0 1px var(--x-accent), inset 0 0 0 2px #ffffff; | |
| } | |
| .suggestions-result-current { | |
| background: var(--x-accent); | |
| } | |
| .vector-menu-tabs .mw-watchlink.icon a:not(:hover) { | |
| filter: grayscale(1); | |
| } | |
| } | |
| } /* @-moz-document */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* ==UserStyle== | |
| @name Wikimedia - Custom fonts | |
| @namespace https://ns.bnay.me/wikimedia/custom-fonts | |
| @version 1.0.0 | |
| @var text u-font-family "Font family" var(--) | |
| @var text u-font-weight "Normal font weight" var(--) | |
| @var text u-font-weight-bold "Bold font weight" var(--) | |
| ==/UserStyle== */ | |
| /* NOTE: inner @media at-rule intentionally not indented */ | |
| @-moz-document regexp("^https:\\/\\/(([^.-]{2,3}(-[^.]+)?|commons|incubator|meta|outreach|simple|species|wiki(mania|tech))\\.(wiki(pedia|news|voyage|quote|versity|source|books|media)|wiktionary)|www\\.(mediawiki|wikidata)|wikisource)\\.org\\/.*") { | |
| @media screen { | |
| :root { | |
| --x-font-family: var(--u-font-family, "Roboto", sans-serif); | |
| --x-font-weight: var(--u-font-weight, normal); | |
| --x-font-weight-bold: var(--u-font-weight-bold, bold); | |
| } | |
| html, body, button, input, select, | |
| h1, h2, h3, h4, h5, h6, | |
| div.vectorMenu h3 span, | |
| div#mw-panel div.portal h3, | |
| .mw-editsection,.mw-editsection-like, | |
| .mw-tag-markers, .ve-ui-overlay, | |
| input[name="target"], input[name="user"], input[name="mime"], input[size$="0"], | |
| input[type="text"], input[type="checkbox"], input[type="radio"], | |
| input#wpTemplateSandboxPage, input.mw-summary, input.mw-input, .mw-input input, | |
| textarea, .mw-ui-input-inline, .mw-ui-input, #searchInput { | |
| font-family: var(--x-font-family); | |
| font-weight: var(--x-font-weight); | |
| } | |
| .mw-body-content #toc h2, .mw-body-content .toc h2 { | |
| font-family: var(--x-font-family); | |
| } | |
| pre, code, textarea, kbd, samp, var, tt, | |
| .mw-code { | |
| font-weight: normal; | |
| } | |
| b, strong, th, | |
| .mw-editform .editHelp a, | |
| strong.selflink, | |
| #interwiki-completelist, | |
| .hlist dd:after,.hlist li:after, | |
| .infobox caption, | |
| #wpSave, | |
| div.NavFrame div.NavHead, | |
| .mw-ext-cite-error, | |
| #pt-notifications-alert .mw-echo-notifications-badge:after,#pt-notifications-notice .mw-echo-notifications-badge:after, | |
| dt, | |
| .unpatrolled, | |
| .newpage,.minoredit,.botedit, | |
| a.mw-selflink, | |
| table.wikitable > caption, | |
| .errorbox h2,.warningbox h2,.successbox h2, | |
| h3,h4,h5,h6, | |
| #toc h2,.toc h2, | |
| .usermessage, | |
| .mw-body-content h3,.mw-body-content h4, | |
| #footer-info-lastmod { | |
| font-weight: var(--x-font-weight-bold); | |
| } | |
| .oo-ui-buttonElement-button, | |
| .page-Main_Page #mw-content-text h2 { | |
| font-weight: var(--x-font-weight-bold) !important; | |
| } | |
| } | |
| } /* @-moz-document */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* ==UserStyle== | |
| @name Wikimedia - Minimal Vector theme | |
| @namespace https://ns.bnay.me/wikimedia/minimal-vector-theme | |
| @version 1.0.0 | |
| @var select u-show-username "Show username?" { | |
| "default:Default (no)*": "var(--)", | |
| "true:Yes": "1", | |
| "false:No": "0" | |
| } | |
| ==/UserStyle== */ | |
| /* NOTE: inner @media at-rule intentionally not indented */ | |
| @-moz-document regexp("^https:\\/\\/(([^.-]{2,3}(-[^.]+)?|commons|incubator|meta|outreach|simple|species|wiki(mania|tech))\\.(wiki(pedia|news|voyage|quote|versity|source|books|media)|wiktionary)|www\\.(mediawiki|wikidata)|wikisource)\\.org\\/.*") { | |
| @media screen { | |
| :root { | |
| --x-show-username: var(--u-show-username, 0); | |
| } | |
| body.skin-vector, | |
| body.skin-vector #mw-page-base { | |
| background: #fff; | |
| } | |
| body.skin-vector .mw-body { | |
| border-color: transparent; | |
| } | |
| body.skin-vector .mw-portlet li:first-child { | |
| margin-inline-start: 0; | |
| } | |
| body.skin-vector #pt-anonuserpage, | |
| body.skin-vector #pt-userpage a { | |
| background-size: 1rem 1rem; | |
| padding-inline-start: 1.125rem !important; | |
| padding-inline-end: 0 !important; | |
| background-position-y: calc(120% / var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector-legacy #pt-anonuserpage, | |
| body.skin-vector-legacy #pt-userpage a { | |
| background-position-y: calc(100% / var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector #pt-uls .uls-trigger:before { | |
| background-position-y: calc(120% / var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector #pt-userpage a { | |
| position: relative; | |
| top: calc(2.75px * var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector #pt-userpage a { | |
| max-width: calc(100vw * var(--x-show-username, 1)); | |
| overflow: hidden; | |
| margin-inline-start: 0.75rem; | |
| margin-inline-end: 0.5rem; | |
| } | |
| body.skin-vector.rtl #pt-userpage a { | |
| margin-inline-start: 0.5rem; | |
| margin-inline-end: 0.75rem; | |
| } | |
| body.skin-vector #pt-notifications-alert .mw-echo-notifications-badge, | |
| body.skin-vector #pt-notifications-notice .mw-echo-notifications-badge { | |
| top: calc(-3px + 5px * (var(--x-scale-factor, 1) - 1)); | |
| opacity: 1; | |
| } | |
| body.skin-vector #pt-notifications-alert .mw-echo-notifications-badge.mw-echo-notifications-badge-all-read, | |
| body.skin-vector #pt-notifications-notice .mw-echo-notifications-badge.mw-echo-notifications-badge-all-read { | |
| opacity: 0.640625; | |
| } | |
| body.skin-vector.skin-vector-disable-max-width .mw-article-toolbar-container { | |
| max-width: none; | |
| } | |
| body.skin-vector #left-navigation { | |
| padding-inline-start: calc(8px * (var(--x-scale-factor, 1) - 1)); | |
| } | |
| body.skin-vector-legacy #left-navigation { | |
| margin-inline-start: 12em !important; | |
| } | |
| body.skin-vector .vector-menu-tabs, | |
| body.skin-vector .vector-menu-tabs li, | |
| body.skin-vector .vector-menu-tabs a, | |
| body.skin-vector #mw-head .vector-menu-dropdown h3 { | |
| background: none; | |
| } | |
| body.skin-vector .vector-menu-dropdown .vector-menu-content { | |
| border-top-width: 1px; | |
| } | |
| body.skin-vector .vector-menu-tabs .selected { | |
| font-weight: bold; | |
| box-shadow: none; | |
| } | |
| body.skin-vector #mw-panel { | |
| width: 10.75em; | |
| background: none; | |
| border-inline-end-color: transparent; | |
| } | |
| body.skin-vector .vector-menu-portal h3 { | |
| background: none; | |
| font-weight: bold; | |
| } | |
| } | |
| /*@media screen and (min-width: 1337px) { | |
| body.skin-vector:not(.skin-vector-disable-max-width):not(.action-history):not(.ns-special) .mw-checkbox-hack-checkbox:checked ~ .mw-workspace-container .mw-content-container, | |
| body.skin-vector:not(.skin-vector-disable-max-width):not(.action-history):not(.ns-special) .mw-checkbox-hack-checkbox:checked ~ .mw-workspace-container .mw-article-toolbar-container { | |
| margin-inline-start: auto; | |
| } | |
| }*/ | |
| } /* @-moz-document */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* ==UserStyle== | |
| @name Wikimedia - Scale text | |
| @namespace https://ns.bnay.me/wikimedia/scale-text | |
| @version 1.0.0 | |
| @var text u-scale-factor "Scale factor" var(--) | |
| ==/UserStyle== */ | |
| /* NOTE: inner @media at-rules intentionally not indented */ | |
| @-moz-document regexp("^https:\\/\\/(([^.-]{2,3}(-[^.]+)?|commons|incubator|meta|outreach|simple|species|wiki(mania|tech))\\.(wiki(pedia|news|voyage|quote|versity|source|books|media)|wiktionary)|www\\.(mediawiki|wikidata)|wikisource)\\.org\\/.*") { | |
| @media screen { | |
| :root { | |
| --x-scale-factor: var(--u-scale-factor, 1.125); | |
| } | |
| body.skin-vector { | |
| font-size: calc(1rem * var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector .mwe-popups { | |
| font-size: calc(0.875rem * var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector .rt-tooltip { | |
| font-size: calc(0.8125rem * var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector .mw-editsection, body.skin-vector .mw-editsection-like { | |
| font-size: calc(0.8125rem * var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector .mw-pt-translate-header { | |
| font-size: calc(0.625rem * var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector #pt-anonuserpage, body.skin-vector #pt-userpage a { | |
| padding-inline-start: calc(16px * var(--x-scale-factor, 1)) !important; | |
| } | |
| body.skin-vector #mw-sidebar-button::before { | |
| margin-inline: auto; max-width: 0; | |
| } | |
| body.skin-vector .mw-editfont-monospace, body.skin-vector .mw-editfont-sans-serif, body.skin-vector .mw-editfont-serif, | |
| body.skin-vector .wikiEditor-ui .ace_editor { | |
| font-size: calc(0.8125rem * var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector .wikiEditor-ui-toolbar .tabs span.tab { | |
| transform: translateY(calc(14px * (var(--x-scale-factor, 1) - 1))); | |
| } | |
| body.skin-vector .ve-init-mw-editSwitch .oo-ui-popupToolGroup { | |
| height: calc(32px * var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector .ve-init-mw-editSwitch .oo-ui-popupToolGroup.oo-ui-iconElement .oo-ui-popupToolGroup-handle { | |
| padding-top: calc(32px * var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector .ve-ui-mwSaveDialog-checkboxes { | |
| margin-inline-end: 0; | |
| } | |
| body.skin-vector .oo-ui-processDialog .oo-ui-actionWidget.oo-ui-labelElement > .oo-ui-buttonElement-button { | |
| padding-block: calc(10px * var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector .oo-ui-popupToolGroup.oo-ui-labelElement .oo-ui-popupToolGroup-handle, | |
| body.skin-vector .oo-ui-tool.oo-ui-tool-with-label .oo-ui-tool-link { | |
| padding-block: calc(11px * var(--x-scale-factor, 1)); | |
| } | |
| body.skin-vector select { | |
| font-size: inherit; | |
| } | |
| } | |
| } /* @-moz-document */ | |
| @-moz-document regexp("^https:\\/\\/([^.]+)\\.wikivoyage\\.org\\/.*") { | |
| @media screen { | |
| body.skin-vector .mw-parser-output #mainpage-map { | |
| font-size: 1.1rem !important; | |
| } | |
| } | |
| } /* @-moz-document */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| set -e | |
| URL='https://gist.github.com/scottywz/263dcd1b6f8470af3e6dc377938e6c89/archive/master.zip' | |
| main() { | |
| if [ $# -ne 1 ]; then | |
| echo "Usage: $(basename -- "$0") {output-path}" >&2 | |
| return 2 | |
| fi | |
| local output="$1" | |
| tmpdir=$(mktemp -d '/dev/shm/wikimedia-user-css.XXXXXX') | |
| trap 'cleanup' INT QUIT 0 | |
| (cd "$tmpdir" && curl -f -L "$URL" -o "archive.zip" && unzip "archive.zip" >&2) | |
| local n=0 | |
| local output_tmp="$tmpdir/out" | |
| printf '' > "$output_tmp" | |
| for path in $(find "$tmpdir" -name '*.user.css' | sort); do | |
| [ $n -gt 0 ] && printf '\n\n' >> "$output_tmp" || true | |
| printf '%s\n' "/* $(basename -- "$path") */" >> "$output_tmp" | |
| printf '%s\n' '' >> "$output_tmp" | |
| cat "$path" \ | |
| | sed -e 's,^\(@-moz-document\s.*\)$,/*\1*/,g' \ | |
| | sed -e 's,^\(\s*}\)\(\s*/\*\s*@-moz-document\s*\*/\)$,/*\1*/\2,g' \ | |
| >> "$output_tmp" | |
| n=$(($n+1)) | |
| done | |
| mv "$output_tmp" "$output" | |
| } | |
| cleanup() { | |
| [ x"$tmpdir" != x"" ] && rm -rf "$tmpdir" || true | |
| } | |
| main "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Wikimedia - Disable global CSS | |
| // @description For use when custom CSS is installed both client-side and at Special:MyPage/global.css on meta.wikimedia.org. | |
| // @namespace https://ns.bnay.me/wikimedia/disable-global-css | |
| // @version 1.0.0 | |
| // @include /^https:\/\/(([^.-]{2,3}(-[^.]+)?|commons|incubator|meta|outreach|simple|species|wiki(mania|tech))\.(wiki(pedia|news|voyage|quote|versity|source|books|media)|wiktionary)|www\.(mediawiki|wikidata))\.org\/.*/ | |
| // @grant none | |
| // @run-at document-start | |
| // ==/UserScript== | |
| function disableIfMatch(link) { | |
| // Disables stylesheets whose URLs match `//meta.wikimedia.org/w/load.php?lang=*&modules=ext.globalCssJs.user.styles&only=styles&*` | |
| if (link && link instanceof HTMLLinkElement && link.href) { | |
| const url = new URL(link.href); | |
| if ( | |
| url.hostname == "meta.wikimedia.org" && | |
| url.pathname == "/w/load.php" && | |
| url.searchParams.get("modules") == "ext.globalCssJs.user.styles" && | |
| url.searchParams.get("only") == "styles" | |
| ) { | |
| link.disabled = true; | |
| // NOTE: the below is needed for Chromium-based browsers | |
| // (see notes for the link[disabled] attribute in <https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement#browser_compatibility>) | |
| link.addEventListener("load", () => link.sheet.disabled = true); | |
| if (link.sheet) { | |
| link.sheet.disabled = true; | |
| } | |
| } | |
| } | |
| } | |
| function main() { | |
| for (const link of document.querySelectorAll("head link")) { | |
| disableIfMatch(link); | |
| } | |
| new MutationObserver((mutations) => { | |
| for (const mutation of mutations) { | |
| for (const node of mutation.addedNodes) { | |
| if (node instanceof HTMLHeadElement) { | |
| new MutationObserver((mutations) => { | |
| for (const mutation of mutations) { | |
| for (const node of mutation.addedNodes) { | |
| if (node instanceof HTMLLinkElement) { | |
| disableIfMatch(node); | |
| } | |
| } | |
| } | |
| }).observe(document.documentElement, { childList: true, subtree: true }); | |
| } | |
| } | |
| } | |
| }).observe(document.documentElement, { childList: true, subtree: false }); | |
| } | |
| main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

