Greasy Fork

Greasy Fork is available in English.

bilibili界面背景更改完整版

try to take over the world!

当前为 2020-07-17 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         bilibili界面背景更改完整版
// @namespace    https://github.com/wuxintlh/
// @version      0.3.1
// @description  try to take over the world!
// @author       桜wuxin
// @match        *://*.bilibili.com/*
// @grant        none
// ==/UserScript==

        var div = document.createElement('div');
        var body = document.querySelector('body');
        var span = document.createElement('span');
        var input = document.createElement('input');
        var button = document.createElement('button');
        var bcurl = '';
        body.appendChild(span);
        span.innerHTML = '点击更换背景';
        span.style.width = '100px';
        span.style.height = '22px';
        span.style.position = 'absolute';
        span.style.top = '940px';
        span.style.left = '0%';
        span.style.backgroundColor = 'rgba(0,255,255,.5)';
        span.style.userSelect = 'none';
        span.style.zIndex = '10';
        body.appendChild(div);
        div.style.backgroundColor = 'rgba(255,0,255,.5)'
        div.style.width = '400px';
        div.style.height = '60px';
        div.style.position = 'absolute';
        div.style.top = '902px'
        div.style.left = '100px';
        div.style.display = 'none';
        div.style.zIndex = '10'
        div.appendChild(input);
        div.appendChild(button);
        input.type = 'text';
        input.placeholder = '请输入完整的背景url';
        input.style.width = '400px';
        button.innerHTML = '点击更换背景';
        button.style.position = 'absolute';
        button.style.top = '30px';
        button.style.left = '150px';


        //弹出框
        span.addEventListener('click', function() {
            if (div.style.display == 'none') {
                div.style.display = 'block';
            } else {
                div.style.display = 'none';
            }
        });
        //更换背景
        button.addEventListener('click', function() {
            bcurl = input.value;
            if (bcurl == '') {
                alert('你没有输入任何内容!');
            } else {
                var div = document.createElement('div');
                var all = document.querySelectorAll('div');
                var last = all.length - 1;
                body.removeChild(all[last]); //删除本脚本产生的最后一个节点
                body.appendChild(div);
                div.dataUname = 'background';
                div.style.backgroundColor = 'white';
                //在本地储存bcurl
                window.localStorage.setItem('bcurl', bcurl);
                div.style.background = 'url(' + bcurl + ')';
                div.style.backfroundRepeat = 'no-repeat';
                div.style.position = 'fixed';
                div.style.backgroundPosition = 'center 0';
                div.style.backgroundSize = 'cover';
                div.style.zoom = '1';
                div.style.width = '100%';
                div.style.height = '100%';
                div.style.top = '0';
                div.style.left = '0';
                div.style.webkitBackgroundSize = 'cover';
                div.style.zIndex = '-1';
            }
        });
        //设置默认背景
        function set() {
            'use strict';
            // Your code here...
            var div = document.createElement('div');
            body.appendChild(div);
            div.dataUname = 'background';
            div.style.backgroundColor = 'white';
            if (window.localStorage.getItem('bcurl') != '' && window.localStorage.getItem('bcurl') != null) {
                div.style.background = 'url(' + window.localStorage.getItem('bcurl') + ')'
            } else {
                div.style.background = 'url(https://i0.hdslb.com/bfs/album/eb65ae5ee6f66b6381090f5bee4fe6cbabfd6d0d.png)'
            }
            div.style.backfroundRepeat = 'no-repeat';
            div.style.position = 'fixed';
            div.style.backgroundPosition = 'center 0';
            div.style.backgroundSize = 'cover';
            div.style.zoom = '1';
            div.style.width = '100%';
            div.style.height = '100%';
            div.style.top = '0';
            div.style.left = '0';
            div.style.webkitBackgroundSize = 'cover';
            div.style.zIndex = '-1';
        };
        set();
        window.addEventListener('scroll', function() {
            span.style.top = this.scrollY + 940 + 'px';
            div.style.top = this.scrollY + 902 + 'px';
        });