您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
随机获取动漫和小仙女图片
当前为
// ==UserScript== // @name 休息一下 // @namespace http://tampermonkey.net/ // @version 1.3 // @description 随机获取动漫和小仙女图片 // @author wangkaixuan // @match http://.com // @include * // @grant none // @license Apache // ==/UserScript== var show = 1;//可修改默认窗口状态,0为显示,1为隐藏 var imgsize=true;let htop = "https://"; //let currentUrl = `https://www.dmoe.cc/random.php`; // 备用 let currentUrl = `${htop}api.yimian.xyz/img?type=head`;//小头像 const animeButton = document.createElement('button'); const sceneryButton = document.createElement('button'); const beautyButton = document.createElement('button'); const cosButton = document.createElement('button'); const videoButton = document.createElement('button'); animeButton.innerText = 'ACG'; sceneryButton.innerText = '风景'; beautyButton.innerText = '小仙女'; cosButton.innerText = 'COS'; videoButton.innerText = '视频'; const magnifyButton = document.createElement('button');//背景按钮 magnifyButton.innerText = '⇱'; const R18input = document.createElement('input');//单选 R18input.type = 'checkbox'; R18input.onchange = (event)=>{ if (R18input.checked=true) {R18yes();} R18input.checked = false; } const spans = document.createElement('div');//单选文本 spans.innerText = '开启R18模式'; const spanp = document.createElement('div');//等待说明 const showbox = document.createElement('div');//位置控制按钮 const directionImage = document.createElement('div');//方向 const randomImage = document.createElement('img');// 创建图片 randomImage.style.width = "310px"; randomImage.onclick =()=>{//单击图片 imgsize=!imgsize; randomImage.style.width =imgsize ? '310px' : '750px'; } const videoye = document.createElement('video');//创建视频 const container = document.getElementById("div"); videoye.width=310; videoye.controls = true; videoye.style.display="none"; // 按钮容器 const buttonContainer = document.createElement('div'); buttonContainer.id="newKuang" buttonContainer.style = ` position: fixed; top: 20px; right: -335px; height: auto; background-color: #FFF; border: 1px solid #CCC; box-shadow: 0px 0px 5px 2px #F5F5F5; border-radius: 10px; padding: 10px; padding-top: 40px; z-index: 9999; transition: all 0.8s ease-out; `;//#F5F5F5乳白色 // 按钮通用样式 const buttonStyle = ` background-color: #F9A7B0; color: #FFF; border: none; font-size:10px; padding: 10px; height: 38px; line-height:18px; border-radius: 8px; margin-right: 10px; cursor: pointer; box-shadow:4px 4px 5px #CCC; `; animeButton.style = buttonStyle; sceneryButton.style = buttonStyle; beautyButton.style = buttonStyle; cosButton.style = buttonStyle; videoButton.style = buttonStyle; //背景按钮样式 magnifyButton.style = ` background-color: rgba(255, 255, 255, 0.8); color: black; border: none; padding: 10px 13px; border-radius:0 10px 0 0; cursor: pointer; position:absolute; top:87px; right:10px; `; magnifyButton.title = `单击设置为当前页面背景图片 (因为跨域问题无法固定某张图片为背景) 鼠标右击单击取消背景图片 (另:单击图片可放大)`; // 说明样式 spanp.innerText = '不同类型图片加载需要不同时间' spanp.style = ` cursor:default; color:#F9A7B0; font-size:10px; position:absolute; padding: 0; top:10px; left:10px; ` // 图片样式 randomImage.style.display = 'block'; randomImage.style.marginTop = '10px'; randomImage.style.borderRadius = '10px'; randomImage.style.transition="all 0.4s linear"; randomImage.alt = "链接已失效" // 单选文本样式 spans.style=` color: black; position:absolute; top:12px; right:10px; font-size:10px; cursor: default;`; // 单选样式 R18input.style=` position:absolute; top:10px; right:80px; cursor: pointer;`; // 方向样式 directionImage.style=` width:0; height:0; border-top:10px solid transparent; border-bottom:10px solid transparent; border-right:10px solid transparent; border-right-color: white; transition:all 0.4s linear;`; // 位置按钮样式 showbox.style=` position:absolute; top:20px; left:-30px; background-color: #F9A7B0; padding: 10px; border-radius: 8px 0 0 8px; margin-right: 10px; cursor: pointer; `; buttonContainer.onmousedown = (event) => {//利用冒泡优化代码 const button = event.target.closest('button'); // 找到最近的button元素 if (button) { button.style.filter = 'brightness(0.9)'; // 设置按钮亮度 } }; buttonContainer.onmouseup = (event) => { const button = event.target.closest('button'); if (button) { button.style.filter = ''; } }; animeButton.onclick = () => { currentUrl = `${htop}www.dmoe.cc/random.php?t=${Date.now()}`; // 使用二次元图片 //api.vvhan.com/api/acgimg getRandomImage(currentUrl); videoye.style.display="none"; magnifyButton.style.display="block"; }; sceneryButton.onclick = () => { currentUrl = `${htop}tu.ltyuanfang.cn/api/fengjing.php?t=${Date.now()}`; // 使用风景图片 getRandomImage(currentUrl); videoye.style.display="none"; magnifyButton.style.display="block"; }; beautyButton.onclick = () => { currentUrl = `${htop}cdn.seovx.com/?mom=302&t=${Date.now()}`; // 使用仙女图片 getRandomImage(currentUrl); videoye.style.display="none"; magnifyButton.style.display="block"; }; cosButton.onclick = () => { currentUrl = `${htop}api.vvhan.com/api/girl?t=${Date.now()}`; // 使用cos图片 getRandomImage(currentUrl); videoye.style.display="none"; magnifyButton.style.display="block"; }; videoButton.onclick = () => { videoye.src=`https://api.qqsuu.cn/api/dm-xjj?type=video`;// 使用视频 videoye.style.display="block"; magnifyButton.style.display="none"; currentUrl = "" getRandomImage(currentUrl); }; magnifyButton.onclick = () => {//背景替换 document.body.style.backgroundImage = `url(${currentUrl})`; localStorage.setItem("BackgroundImage", randomImage.src);//保存 backgroundBurden() }; magnifyButton.addEventListener("contextmenu", function(event) {//普通事件会覆盖,使用addEventListener注册可以避免 event.preventDefault(); // 阻止默认事件,即不弹出上下文菜单 localStorage.removeItem("BackgroundImage");//删除 location.replace(location.href); }); // 将按钮和图片添加到容器中 buttonContainer.appendChild(spanp);//等待文本 buttonContainer.appendChild(animeButton);//动漫按钮 buttonContainer.appendChild(sceneryButton);//风景按钮 buttonContainer.appendChild(beautyButton);//仙女按钮 buttonContainer.appendChild(cosButton);//COS按钮 buttonContainer.appendChild(videoButton);//视频按钮 buttonContainer.appendChild(randomImage);//图片 buttonContainer.appendChild(videoye);//视频 showbox.appendChild(directionImage);//方向 buttonContainer.appendChild(showbox);//位置 buttonContainer.appendChild(magnifyButton);//背景 buttonContainer.appendChild(R18input);//单选 buttonContainer.appendChild(spans);//单选文本 document.body.appendChild(buttonContainer); function R18yes(){//戏耍 const result = confirm('⚠️您已经年满180周岁?'); if (result) { alert('〠经过系统检测,你未满180周岁,根据《未成年人保护法》你无法访问R18内容!'); }} function getRandomImage(url) {//链接 randomImage.src = url; } function shows(){//控制移动 if(show){ buttonContainer.style.right = '20px'; directionImage.style.transform = 'rotate(-180deg)' show=!show }else{ buttonContainer.style.right = '-335px'; directionImage.style.transform = 'rotate(0deg)'; imgsize=true; randomImage.style.width ='310px' show=!show } } function backgroundBurden(){//背景样式 const divs = document.querySelectorAll('body > div:not(#newKuang)'); const ps = document.querySelectorAll('p,img,span,h1,h2,h3,video'); divs.forEach(di => { if (di.style.backgroundColor) { di.style.opacity = '0.8'; } else { di.style.backgroundColor = 'rgba(255, 255, 255, 0.6)'; } }) ps.forEach(p1 => { p1.style.opacity = '1'; }); document.body.style.backgroundRepeat="no-repeat"; document.body.style.backgroundAttachment= "fixed"; document.body.style.backgroundSize="cover"; } showbox.onclick = () => {//改变位置 getRandomImage(currentUrl) shows() }; // 从localStorage中读取BackgroundImage的值 var backgroundImage = localStorage.getItem("BackgroundImage");//读取 window.addEventListener('load', () => { if (backgroundImage) { document.body.style.backgroundImage = "url('" + backgroundImage + "')"; backgroundBurden() } });