|
本帖最后由 yyy1013 于 2024-10-21 13:16 编辑
哦哈哟,朋友们,我来了。
您是否觉得论坛的壁纸看太久了,没有**(我在此声明,没有任何对于论坛,站长,同好们的不尊重,论坛原本的背景我也很喜欢)
您是否觉得在看文时一片空白,啥也不是
您是否需要边看自己老婆,边***
在论坛里潜水老久了,感觉也应该为网站的朋友们做点什么......
所以,我手搓了一点可以更换网站背景的小东西。(甚至支持FDT小说站)
- <font _mstmutation="1" _msttexthash="399178493961" _msthash="120">==UserScript==
- @name skunkgirl 背景
- @version 1.0
- @description 将网页的背景更改为您选择的图片。按 F2 将背景更改为在线图片,按 F7 将背景更改为本地图片,按 F4 更改前景元素的不透明度。(根据你选择的图片更换网页的背景,按F2更换背景为网络图片,按F7更换背景为本地图片,按F4改变前景元素的透明度。)
- @author yyy1013
- @require http://cdn.bootcss.com/jquery/1.8.3/jquery.min.js
- @match https://www.skunkgirl.cc/*
- @match https://video.fdtstudio.org/*
- @match https://*/*
- @grant GM_setValue
- @grant GM_getValue
- @grant GM_addStyle @noframes
- ==/UserScript==
- (function() {
- 'use strict';
- let url = GM_getValue('url');
- let opacity = GM_getValue('opacity');
- if (opacity == undefined) opacity = '0.8';
- function ChangeOpacity() {
- $('body').children('#GM_Background').css('opacity', (1 - parseFloat(opacity)).toString());
- }
- function AddValuebar() {
- GM_addStyle('#GM_ValuebarContainer { position: fixed; top: 40px; left: 45%; width: 15%; height: 20px; background-color: #66cccc; display: none; border: 0.5px solid; border-radius: 8px; z-index: 10000; }');
- GM_addStyle('#GM_Valuebar { -webkit-appearance: none; transform: translateX(5%); width: 91%; height: 100%; background-color: #0000; }');
- GM_addStyle('#GM_Valuebar::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; transform: translateY(-3px); border-radius: 7px; border: 0.5px solid #000; background-color: #ff99cc; }');
- GM_addStyle('#GM_Valuebar::-webkit-slider-runnable-track { -webkit-appearance: none; height: 8px; border-radius: 4px; border: 0.5px solid #000; background-color: #ccff66; }');
- GM_addStyle('#GM_Background { 位置:固定;顶部:0;左侧:0;z-index:9999;指针事件:无; }');
- let valuebar = '<div id=“GM_ValuebarContainer”><input type=“range” id=“GM_Valuebar” min=“0.0” max=“1.0” step=“0.05” value=“' + opacity + '”></div>';
- $('body').append(值栏);
- $('#GM_Valuebar').change(() => {
- opacity = document.getElementById('GM_Valuebar').value.toString();
- GM_setValue('opacity', opacity);
- ChangeOpacity(不透明度);
- });
- $(document).keydown((event) => {
- if (event.which == 115) {
- let tag = $('#GM_ValuebarContainer');
- if (tag.css('display') == 'none') tag.css('display', 'block'); else tag.css('display', 'none');
- }
- });
- }
- function DrawBackground(url) {
- let canvas = $('#GM_Background')[0];
- let scale = window.devicePixelRatio / 1.25;
- canvas.width = screen.width / scale;
- canvas.height = screen.height / scale;
- let ctx = canvas.getContext('2d');
- let img = new Image(); img.src = url;
- img.onload = () => {
- let midx = img.width / 2, midy = img.height / 2;
- 设 imgscale = Math.max(canvas.width / 2 / midx,
- canvas.width / 2 / (img.width - midx),
- canvas.height / 2 / midy,
- canvas.height /2 / (img.height - midy));
- ctx.scale(imgscale, imgscale);
- ctx.drawImage(img, canvas.width / 2 - midx * imgscale, canvas.height / 2 - midy * imgscale);
- };
- }
- function AddBackground() {
- let background = '<canvas id=“GM_Background”></canvas>';
- $('body').append(background);
- DrawBackground(url) 的 DrawBackground(url);
- ChangeOpacity(不透明度);
- AddValuebar();
- }
- if (url != undefined) {
- AddBackground();
- $(document).keydown((event) =>
- { if (event.which == 113) {
- var geturl = prompt('请输入图片的网址,按确定生效。\n请输入图片的网址,按 OK 生效。
- if (geturl != null) {
- GM_setValue('url', geturl);
- document.body.style = “background:rgba(0, 0, 0,0) url(geturl) 无重复固定;background-size:100% auto“;
- }
- teste(document.getElementsByTagName(“div”));
- function teste(array){
- for(var i=0; i<array.length; i++)
- {
- array[i].style.backgroundColor=“rgba(229, 241, 240,0)”;
- teste(array[i].getElementsByTagName(“div”));
- }
- }
- // console.log(“baolihou: 背景图片清晰”);
- if (url == undefined) { url = geturl;添加背景();}
- // else { url = geturl;DrawBackground(url) 的 DrawBackground(url);}</font>
- }
- });
- })();
复制代码
本地图片的功能暂无(咕咕咕)
把它复制进去,点击保存并关闭。
接着,回到论坛,点击f2,将自己喜欢的壁纸网址加入进去就OK了
本废物只是一个萌新,如有不好的,欢迎各位指出并纠正。
|
|