臭鼬娘  
  
查看: 550|回复: 5

一些关于网站的美化

[复制链接]

4

主题

57

帖子

84

积分

注册会员

Rank: 2

积分
84
发表于 昨天 13:09 | 显示全部楼层 |阅读模式
本帖最后由 yyy1013 于 2024-10-21 13:16 编辑

哦哈哟,朋友们,我来了。
您是否觉得论坛的壁纸看太久了,没有**(我在此声明,没有任何对于论坛,站长,同好们的不尊重,论坛原本的背景我也很喜欢)

您是否觉得在看文时一片空白,啥也不是

您是否需要边看自己老婆,边***

在论坛里潜水老久了,感觉也应该为网站的朋友们做点什么......
所以,我手搓了一点可以更换网站背景的小东西。(甚至支持FDT小说站)



  1. <font _mstmutation="1" _msttexthash="399178493961" _msthash="120">==UserScript==
  2. @name skunkgirl 背景
  3. @version 1.0
  4. @description 将网页的背景更改为您选择的图片。按 F2 将背景更改为在线图片,按 F7 将背景更改为本地图片,按 F4 更改前景元素的不透明度。(根据你选择的图片更换网页的背景,按F2更换背景为网络图片,按F7更换背景为本地图片,按F4改变前景元素的透明度。)
  5. @author yyy1013
  6. @require http://cdn.bootcss.com/jquery/1.8.3/jquery.min.js
  7. @match https://www.skunkgirl.cc/*
  8. @match https://video.fdtstudio.org/*
  9. @match https://*/*
  10. @grant GM_setValue

  11. @grant GM_getValue
  12. @grant GM_addStyle @noframes
  13. ==/UserScript==

  14. (function() {
  15. 'use strict';

  16. let url = GM_getValue('url');
  17. let opacity = GM_getValue('opacity');
  18. if (opacity == undefined) opacity = '0.8';

  19. function ChangeOpacity() {
  20. $('body').children('#GM_Background').css('opacity', (1 - parseFloat(opacity)).toString());
  21. }

  22. function AddValuebar() {
  23. 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; }');
  24. GM_addStyle('#GM_Valuebar { -webkit-appearance: none; transform: translateX(5%); width: 91%; height: 100%; background-color: #0000; }');
  25. 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; }');
  26. GM_addStyle('#GM_Valuebar::-webkit-slider-runnable-track { -webkit-appearance: none; height: 8px; border-radius: 4px; border: 0.5px solid #000; background-color: #ccff66; }');
  27. GM_addStyle('#GM_Background { 位置:固定;顶部:0;左侧:0;z-index:9999;指针事件:无; }');
  28. let valuebar = '<div id=“GM_ValuebarContainer”><input type=“range” id=“GM_Valuebar” min=“0.0” max=“1.0” step=“0.05” value=“' + opacity + '”></div>';
  29. $('body').append(值栏);
  30. $('#GM_Valuebar').change(() => {
  31. opacity = document.getElementById('GM_Valuebar').value.toString();
  32. GM_setValue('opacity', opacity);
  33. ChangeOpacity(不透明度);
  34. });
  35. $(document).keydown((event) => {
  36. if (event.which == 115) {
  37. let tag = $('#GM_ValuebarContainer');
  38. if (tag.css('display') == 'none') tag.css('display', 'block'); else tag.css('display', 'none');
  39. }
  40. });
  41. }

  42. function DrawBackground(url) {
  43. let canvas = $('#GM_Background')[0];
  44. let scale = window.devicePixelRatio / 1.25;
  45. canvas.width = screen.width / scale;
  46. canvas.height = screen.height / scale;
  47. let ctx = canvas.getContext('2d');
  48. let img = new Image(); img.src = url;
  49. img.onload = () => {
  50. let midx = img.width / 2, midy = img.height / 2;
  51. 设 imgscale = Math.max(canvas.width / 2 / midx,
  52. canvas.width / 2 / (img.width - midx),
  53. canvas.height / 2 / midy,
  54. canvas.height /2 / (img.height - midy));
  55. ctx.scale(imgscale, imgscale);
  56. ctx.drawImage(img, canvas.width / 2 - midx * imgscale, canvas.height / 2 - midy * imgscale);
  57. };
  58. }

  59. function AddBackground() {
  60. let background = '<canvas id=“GM_Background”></canvas>';
  61. $('body').append(background);
  62. DrawBackground(url) 的 DrawBackground(url);
  63. ChangeOpacity(不透明度);
  64. AddValuebar();
  65. }

  66. if (url != undefined) {
  67. AddBackground();


  68. $(document).keydown((event) =>
  69. { if (event.which == 113) {
  70. var geturl = prompt('请输入图片的网址,按确定生效。\n请输入图片的网址,按 OK 生效。
  71. if (geturl != null) {
  72. GM_setValue('url', geturl);
  73. document.body.style = “background:rgba(0, 0, 0,0) url(geturl) 无重复固定;background-size:100% auto“;

  74. }
  75. teste(document.getElementsByTagName(“div”));
  76. function teste(array){
  77. for(var i=0; i<array.length; i++)
  78. {
  79. array[i].style.backgroundColor=“rgba(229, 241, 240,0)”;
  80. teste(array[i].getElementsByTagName(“div”));
  81. }
  82. }
  83. // console.log(“baolihou: 背景图片清晰”);
  84. if (url == undefined) { url = geturl;添加背景();}
  85. // else { url = geturl;DrawBackground(url) 的 DrawBackground(url);}</font>
  86.         }
  87.     });

  88. })();
复制代码

本地图片的功能暂无(咕咕咕)

把它复制进去,点击保存并关闭。

接着,回到论坛,点击f2,将自己喜欢的壁纸网址加入进去就OK了

本废物只是一个萌新,如有不好的,欢迎各位指出并纠正。


只是一只想要更文的鸽子罢了————咕咕咕
回复

使用道具 举报

6

主题

150

帖子

3065

积分

论坛元老

Rank: 8Rank: 8

积分
3065
QQ
发表于 昨天 15:22 来自手机 | 显示全部楼层
我嘞个c语言啊,牛逼
回复

使用道具 举报

60

主题

1201

帖子

3442

积分

论坛元老

御坂

Rank: 8Rank: 8

积分
3442

原创作者论坛元老

发表于 昨天 20:30 来自手机 | 显示全部楼层
超牛的!最近一直在捣鼓用Tampermonkey或Stylus美化自己常用的网站(比如洛谷),不过实在是没有往美化论坛那里想hh

但是楼主发的这串码我没看出来是什么...看起来是Tampermonkey脚本,但是我尝试了一下导入结果报了一堆error(hhh)

总之还是超级牛的!(以及video.fdtstudio.org是播放站不是小说站哦hh)
回复

使用道具 举报

37

主题

1359

帖子

1390

积分

金牌会员

路天林

Rank: 6Rank: 6

积分
1390

论坛元老

发表于 昨天 20:49 | 显示全部楼层
马牛逼 发表于 2024-10-21 15:22
我嘞个c语言啊,牛逼

js代码吧,这咋是C语言了
回复

使用道具 举报

37

主题

1359

帖子

1390

积分

金牌会员

路天林

Rank: 6Rank: 6

积分
1390

论坛元老

发表于 昨天 20:53 | 显示全部楼层
御坂球 发表于 2024-10-21 20:30
超牛的!最近一直在捣鼓用Tampermonkey或Stylus美化自己常用的网站(比如洛谷),不过实在是没有往美化论坛 ...

给我看无语了,他括号打的都是中文括号...肯定报错的
回复

使用道具 举报

60

主题

1201

帖子

3442

积分

论坛元老

御坂

Rank: 8Rank: 8

积分
3442

原创作者论坛元老

发表于 昨天 20:54 来自手机 | 显示全部楼层
1436735995 发表于 2024-10-21 20:49
js代码吧,这咋是C语言了

y,确实不是C的语法
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 氵主廾廾

本版积分规则

快速回复 返回顶部 返回列表