Skip to content

Instantly share code, notes, and snippets.

@Ser-Gen
Last active October 22, 2019 00:43
Show Gist options
  • Save Ser-Gen/6d3210d4cc138d335376d950ecc789e4 to your computer and use it in GitHub Desktop.
Save Ser-Gen/6d3210d4cc138d335376d950ecc789e4 to your computer and use it in GitHub Desktop.
dark.user.js
// ==UserScript==
// @name dark
// @namespace styles
// @include http*//*.*
// @version 5
// @run-at document-start
// @grant none
// ==/UserScript==
if (window.location.href.match('scinquisitor.livejournal.com')) {
document.documentElement.insertAdjacentHTML('afterbegin', `
<style>
* { background-color: #333 !important; color: #ddd !important; }
body { background-color: #333 !important; color: #ddd !important; font-size: 18px !important; margin: 10px 20px !important; width: 60vw !important; font-family: 'Segoe UI', sans-serif !important; line-height: 1.5em !important; }
a { color: #2be !important; }
* { max-width: calc(60vw - 20px) !important; }
img { height: auto !important; }
</style>
`);
}
// else if (window.location.href.match(/youtu[\.]?be(\.com)?\//)) {
// var yt = window.location.href.match(/^.*(youtu.be\/|v\/|u\/\w\/|watch\?v=|\&v=)([^\&]*)(.*$)/);
// var result = '';
// if (yt && !yt[1].match(/embed/) && yt[2]) {
// result = 'https://www.youtube.com/embed/'+ yt[2];
// if (yt[3]) {
// result += yt[3].replace(/\&feature=youtu\.be/, '').replace('t=', 'start=');
// };
// };
// window.location.href = result;
// }
else if (window.location.href.match('youtrack.(samsonpost|intsite)')) {
document.documentElement.insertAdjacentHTML('afterbegin', `
<style>
body {
background-color: #333 !important;
color: #fff !important;
}
.search-panel {
background-image: none !important;
-webkit-box-shadow: none !important;
-moz-box-shadow: none !important;
box-shadow: none !important;
}
a,
.issueId_fsi,
a.issueId_fsi,
.fsi-properties .fsi-property .attribute.attribute,
.jt-tabpanel-item .jt-panel-title {
color: #7ab3f5 !important;
}
.ring-input {
background-color: #333 !important;
color: #fff !important;
}
.comment-textarea-container {
border-color: #555 !important;
}
.fsi-properties-container {
background: transparent !important;
}
.fsi-properties td {
border-bottom: 1px solid #555 !important;
}
.issues-wrapper {
background: transparent !important;
}
.issue-selected,
.comment-selected {
background-color: #0b285433 !important;
}
.issueContainer {
border-bottom-color: #555 !important;
}
.description_fsi,
.jt-panel-active div {
color: #fff !important;
}
.toolbar-unpined {
background-color: #333 !important;
}
.comment-change-wrapper {
background-color: #444 !important;
}
.add-comment .comment-textarea {
color: #fff !important;
}
.comboboxList {
background-color: #555 !important;
}
.ring-tabs__btn__counter,
.yt-action {
color: inherit !important;
}
.jt-tabpanel-item.jt-panel-active,
.fsi__sidebar__bottom_sticky {
background-color: transparent !important;
}
.fsi__visibility {
background: none !important;
}
.disabled.disabled * {
color: #fff !important;
}
.diff-del {
background-color: #FC8C8C4D !important;
}
.diff-ins {
background-color: #73FC734D !important;
}
.history-item-title {
background-color: transparent !important;
}
</style>
`);
}
else {
var styles = `
<style>
@media screen {
window,
page,
html,
img:not(.mwe-math-fallback-image-inline):not([alt="inline_formula"]), /* TODO: "black on transparent" mark */
embed[type="application/x-shockwave-flash"],
object[type="application/x-shockwave-flash"],
video
{
filter: invert(100%) hue-rotate(180deg) !important;
}
/* fix for #28 */
:fullscreen video,
video:fullscreen
{
filter: none !important;
}
html {
background-color: black !important;
}
button,
input,
optgroup,
select,
textarea {
background-color: white;
color: black;
}
/*@-moz-document domain(facebook.com) {
}*/
@-moz-document regexp(".*\\.pdf$") {
html {
filter: none !important;
}
body {
background-color: #{default_pdf_color} !important;
}
#toolbarContainer, .findbar, .secondaryToolbar {
background-image: none !important;
background-color: #{default_pdf_color} !important;
}
#viewerContainer {
filter: invert(100%) hue-rotate(180deg) !important;
}
.pdfViewer .page {
border-image: none !important;
}
}
}
</style>
`;
if (
needDark()
) {
document.documentElement.insertAdjacentHTML('afterbegin', styles);
}
};
function needDark () {
var result = !window.location.href.match('tools.samsonpost.ru/kb')
&& !window.location.href.match('tools.samsonpost.ru/startpage')
&& !window.location.href.toLowerCase().match(/\.(png|jpg|jpeg|gif)$/)
&& !window.location.href.match('officemag.ru')
&& !window.location.href.match('samsonopt.ru')
&& !window.location.href.match('office-planet.ru')
&& !window.location.href.match('office-zakaz.ru')
&& !window.location.href.match('samsonpost.ru/assets')
&& !window.location.href.match('ibt')
&& !window.location.href.match('brauberg.com')
&& !window.location.href.match('kanzelaria.ru')
&& !window.location.href.match('laima.info')
&& !window.location.href.match('brabix.info')
&& !window.location.href.match('sonnen.me')
&& !window.location.href.match('mygalant.ru')
&& !window.location.href.match('unlandia.com')
&& !window.location.href.match('copycenter.officemag.ru')
&& !window.location.href.match('tiger-family.ru')
&& !window.location.href.match('tigerfamily.ru')
&& !window.location.href.match('bestar-lux.com')
&& !window.location.href.match('pixhub.samsonpost.ru/tools/_youtrack')
&& !window.location.href.match('pixhub.samsonpost.ru/?')
&& !window.location.href.match('samsonpost.ru/bitrix/tools/disk')
&& !window.location.href.match('some.samsonpost.ru')
;
if (
window.location.href.match('mail.corp.samsonopt')
|| window.location.href.match('pixhub.samsonpost.ru/api')
|| window.location.href.match('pixhub.samsonpost.ru/tools')
) {
result = true;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment