Greasy Fork

Greasy Fork is available in English.

bilibili界面背景更改完整版

try to take over the world!

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

        var bcurl = '';
        var host = window.location.host;
        if (host != 'live.bilibili.com') {
            spandiv();
        } else {
            var main = document.querySelector('.live-room-app').querySelector('.z-app-content');
            if (main != true) {
                    var div = document.createElement('div');
                    var span = document.createElement('span');
                    var input = document.createElement('input');
                    var button = document.createElement('button');
                    main.appendChild(span);
                    span.innerHTML = '点击更换背景';
                    span.className = 'SakuraSpans';
                    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';
                    main.appendChild(div);
                    div.className = 'SakuraDivd';
                    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';
                    input.className = 'SakuraInputi';
                    button.innerHTML = '点击更换背景';
                    button.style.position = 'absolute';
                    button.style.top = '30px';
                    button.style.left = '150px';
                    button.className = 'SakuraButtonb';
            }
        };

        function spandiv() {
            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');
            body.appendChild(span);
            span.innerHTML = '点击更换背景';
            span.className = 'SakuraSpans';
            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.className = 'SakuraDivd';
            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';
            input.className = 'SakuraInputi';
            button.innerHTML = '点击更换背景';
            button.style.position = 'absolute';
            button.style.top = '30px';
            button.style.left = '150px';
            button.className = 'SakuraButtonb';
        }
        window.addEventListener('scroll', function() {
            var span = document.querySelector('.SakuraSpans');
            var div = document.querySelector('.SakuraDivd');
            span.style.top = this.scrollY + 940 + 'px';
            div.style.top = this.scrollY + 902 + 'px';
        })


        //弹出框
        span = document.querySelector('.SakuraSpans');
        span.addEventListener('click', function() {
            div = document.querySelector('.SakuraDivd');
            if (div.style.display == 'none') {
                div.style.display = 'block';
            } else {
                div.style.display = 'none';
            }
        });
        //更换背景
        button = document.querySelector('.SakuraButtonb')
        button.addEventListener('click', function() {
            var input = document.querySelector('.SakuraInputi');
            bcurl = input.value;
            if (bcurl == '') {
                alert('你没有输入任何内容!');
            } else {
                var div = document.createElement('div');
                var all = document.querySelectorAll('div');
                var last = all.length - 1;
                var body = document.querySelector('body');
                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';
                div.className = 'SakuraBackground';
            }
        });
        //设置默认背景
        function set() {
            'use strict';
            // Your code here...
            var body = document.querySelector('body');
            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';
            div.className = 'SakuraBackground';
        };
        set();