bilibili dark mode

turn your bilibili (web page) to dark mode

当前为 2022-02-06 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         bilibili dark mode
// @namespace   none
// @version      1.1
// @description  turn your bilibili (web page) to dark mode
// @author       WhiteNightAWA
// @license MIT
// @match        https://www.bilibili.com/*
// @match        https://live.bilibili.com/*
// @match        https://space.bilibili.com/*
// @match        https://search.bilibili.com/*
// @icon         https://icons-for-free.com/iconfiles/png/512/bilibili-1324440130309119028.png
// @grant        none
// ==/UserScript==

function addStyle (cssStr) {
    var D = document;
    var newNode = D.createElement ('style');
    newNode.textContent = cssStr;

    var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
    targ.appendChild (newNode);
}

const url = location.href;

console.log(url);


if (url.startsWith("https://www.bilibili.com/video/")) {
    console.log("this is a video page");
    addStyle ( `

html {
  filter: invert(100%) hue-rotate(180deg);
}

.bilibili-player-video-wrap, img, .van-framepreview {
filter: invert(100%) hue-rotate(180deg);
}

` );
    return;
} else if (url.startsWith("https://www.bilibili.com")) {
    console.log("this is the main page");
    addStyle(`

html {
  filter: invert(100%) hue-rotate(180deg);
}

img, video, em, .mask  {
  filter: invert(100%) hue-rotate(180deg);
}


`);

} else if (url.startsWith("https://live.bilibili.com/")) {

    console.log("this is a live page");
    addStyle ( `

html {
  filter: invert(100%) hue-rotate(180deg);
}

img, video, em, .img-content, .user-avatar, .mask, .item-wrapper, .emoticons-panel, .top3-face, .guard-ent  {
  filter: invert(100%) hue-rotate(180deg);
}

` );
} else if (url.startsWith("https://space.bilibili.com/")) {
    console.log("this is a space page");
    addStyle(`
    html {
  filter: invert(100%) hue-rotate(180deg);
}

.bilibili-player-video-wrap, video, img, .h-inner, .preview-bg, .fake-danmu, .preview-wrapper, .bili-avatar {
  filter: invert(100%) hue-rotate(180deg);
}
    `);
} else if (url.startsWith("https://search.bilibili.com/")) {
    console.log("this is a search page");
    addStyle(`
    html {
  filter: invert(100%) hue-rotate(180deg);
}

img, video, em, .img-content, .user-avatar, .mask, .item-wrapper, .emoticons-panel, .top3-face, .guard-ent, .van-framepreview  {
  filter: invert(100%) hue-rotate(180deg);
}

`)
} else {
    console.log("wtf???");
};