休息一下

随机获取动漫和小仙女图片

目前为 2023-04-10 提交的版本。查看 最新版本

// ==UserScript==
// @name         休息一下
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  随机获取动漫和小仙女图片
// @author       wangkaixuan
// @match        http://.com
// @include *
// @grant        none
// @license      Apache
// ==/UserScript==
var [show,seconds,imgsize,htop,result] = [1,0,true,"https://","18认证"]
//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 = "320px";
randomImage.onclick =()=>{//单击图片
    imgsize=!imgsize;
    randomImage.style.width =imgsize ? '320px' : '750px';
}
randomImage.addEventListener("contextmenu", function(event) {//右击
      event.preventDefault(); // 阻止默认事件,即不弹出上下文菜单
      result = prompt("恭喜你找到了真正的R18入口,请联系作者证明你已满18岁");
      if(result=="金岂"){animeButton.style.backgroundColor="Gold";cosButton.style.backgroundColor="Gold"}
    });
const videoye = document.createElement('video');//创建视频
const container = document.getElementById("div");
videoye.width=320;
videoye.controls = true;
videoye.autoplay = true;
videoye.style.display="none";
videoye.muted = true;//////

// 按钮容器
const buttonContainer = document.createElement('div');
buttonContainer.id="newKuang"
buttonContainer.style = `
  position: fixed;
  top: 20px;
  right: -340px;
  height: auto;
  min-height:100px;
  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:14px;
  padding: 10px;
  height: 38px;
  line-height:18px;
  border-radius: 8px;
  margin-right: 10px;
  cursor: pointer;
  box-shadow:4px 4px 5px #CCC;
  transition: background-color 2s ease-out;
`;
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:97px;
  right:9px;
`;
magnifyButton.title =
`单击设置为当前页面背景图片
(因为跨域问题无法固定某张图片为背景)
鼠标右击单击取消背景图片
(另:单击图片可放大)`;

// 说明样式
spanp.innerText ="不同类型图片加载需要不同时间"
spanp.style = `
cursor:default;
color:#F9A7B0;
font-size:10px;
position:absolute;
padding: 0;
top:10px;
left:10px;
font-weight:bold;
`
// 图片样式
randomImage.style.display = 'block';
randomImage.style.marginTop = '20px';
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.8)'; // 设置按钮亮度
  }
};
buttonContainer.onmouseup = (event) => {
  const button = event.target.closest('button');
    if (button) {
            button.style.filter = '';
    }
};
// --
animeButton.onclick = () => {
  if(result=="金岂"){
    currentUrl = `${htop}sex.nyan.xyz/api/v2/img?r18=true`
    // https://moe.anosu.top/img?sort=setu 备用
  }else{
    currentUrl = `${htop}service-dn725wcs-1306777571.gz.apigw.tencentcs.com/release/?t=${Date.now()}`; // 使用二次元图片
    //api.vvhan.com/api/acgimg
  }
  getRandomImage(currentUrl);
  videoye.style.display="none";
  magnifyButton.style.display="block";
};
animeButton.addEventListener("contextmenu", function(event) {//右击
      event.preventDefault();
      if(result=="金岂"){
    currentUrl = `${htop}image.anosu.top/pixiv/?r18=1&t=${Date.now()}`
  }else{
currentUrl = `${htop}www.dmoe.cc/random.php?t=${Date.now()}`;
  }
  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";
};
sceneryButton.addEventListener("contextmenu", function(event) {//右击
      event.preventDefault();
currentUrl = `${htop}t.lizi.moe/fj?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";
};
beautyButton.addEventListener("contextmenu", function(event) {//右击
      event.preventDefault();
currentUrl = `${htop}api.btstu.cn/sjbz/api.php?t=${Date.now()}`;
  getRandomImage(currentUrl);
  videoye.style.display="none";
  magnifyButton.style.display="block";
    });
// --
cosButton.onclick = () => {
  if(result=="金岂"){
    currentUrl = `${htop}image.anosu.top/pixiv/direct?r18=1&keyword=frontline&t=${Date.now()}`
  }else{
    currentUrl = `${htop}api.vvhan.com/api/girl?t=${Date.now()}`; // 使用cos图片
  }
  getRandomImage(currentUrl);
  videoye.style.display="none";
  magnifyButton.style.display="block";
};
cosButton.addEventListener("contextmenu", function(event) {//右击
      event.preventDefault();
      if(result=="金岂"){
    currentUrl = `${htop}image.anosu.top/pixiv/direct?r18=1&keyword=princess&t=${Date.now()}`
  }else{
    currentUrl = `${htop}api.r10086.com/img-api.php?type=%E6%97%A5%E6%9C%ACCOS%E4%B8%AD%E5%9B%BDCOS&t=${Date.now()}`;
  }
  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);
};
videoButton.addEventListener("contextmenu", function(event) {//右击
      event.preventDefault();
currentUrl = `${htop}tucdn.wpon.cn/api-girl/index.php`;
  getRandomImage(currentUrl);
  videoye.style.display="none";
  magnifyButton.style.display="block";
    });
// --
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 = '-340px';
    directionImage.style.transform = 'rotate(0deg)';
    imgsize=true;
    randomImage.style.width ='320px'
    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();
var timer = setInterval(function() {
  seconds++;
  spanp.innerText = seconds%2 ? "鼠标左击和右击是不同图源" : "不同类型图片加载需要不同时间"
  if (seconds > 2) {
    clearInterval(timer); // 停止计时器
  }
}, 5000);
// Math.floor(Math.random() * 2)
};

// 从localStorage中读取BackgroundImage的值
var backgroundImage = localStorage.getItem("BackgroundImage");//读取
window.addEventListener('load', () => {

if (backgroundImage) {
  document.body.style.backgroundImage = "url('" + backgroundImage + "')";
  backgroundBurden()
}
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址