Greasy Fork is available in English.
在你的浏览器上添加文学社所有女生的Q版形象
当前为
// ==UserScript==
// @name 文学社在看着你👀
// @namespace https://world.xiaomawang.com/w/person/project/all/3267489
// @version 1.6
// @description 在你的浏览器上添加文学社所有女生的Q版形象
// @author 茶铭
// @match *://*/*
// @icon https://ddlc.moe/images/favicon.ico
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
const imageUrls = [
"https://ddlc.moe/images/sticker_s.png",
"https://ddlc.moe/images/sticker_y.png",
"https://ddlc.moe/images/sticker_m.png",
"https://ddlc.moe/images/sticker_n.png"
];
const links = [
"https://chat.monika.love/",
"https://wiki.monika.love/index.php?title=%E9%A6%96%E9%A1%B5",
"https://disk.monika.love/",
"https://forum.monika.love/"
];
const descriptions = [
"DCC chat",
"DCC wiki",
"莫盘",
"心跳文学部中文论坛"
];
const images = [];
const imagePositions = [];
function createImage(url, link, description, x) {
const a = document.createElement('a');
a.href = link;
a.title = `前往 ${description}`;
const img = document.createElement('img');
img.src = url;
img.style.position = 'fixed';
img.style.bottom = '0';
img.style.left = `${x}px`;
img.style.zIndex = '9999';
a.appendChild(img);
document.body.appendChild(a);
return img;
}
function jumpAnimation(img) {
const jumpHeight = 70;
const jumpDuration = Math.floor(Math.random() * 70) + 240;
img.animate([
{ transform: 'translateY(0)', },
{ transform: `translateY(-${jumpHeight}px)`, },
{ transform: 'translateY(0)', }
], {
duration: jumpDuration,
easing: 'ease-in-out',
iterations: 1
});
}
function checkOverlap(x) {
for (let i = 0; i < imagePositions.length; i++) {
const position = imagePositions[i];
if (Math.abs(x - position) <= 100) {
return true;
}
}
return false;
}
function generateRandomX() {
let x = Math.floor(Math.random() * (window.innerWidth - 100));
while (checkOverlap(x)) {
x = Math.floor(Math.random() * (window.innerWidth - 100));
}
return x;
}
function startJumpAnimation() {
const randomIndex = Math.floor(Math.random() * images.length);
jumpAnimation(images[randomIndex]);
const randomInterval = Math.floor(Math.random() * 3000) + 3000;
setTimeout(startJumpAnimation, randomInterval);
}
function toggleImagesVisibility() {
images.forEach(img => {
img.style.display = img.style.display === 'none' ? 'block' : 'none';
});
}
window.addEventListener('load', () => {
imageUrls.forEach((url, index) => {
const x = generateRandomX();
const img = createImage(url, links[index], descriptions[index], x);
images.push(img);
imagePositions.push(x);
});
startJumpAnimation();
document.addEventListener('keydown', event => {
if (event.key === 'n' || event.key === 'N') {
toggleImagesVisibility();
}
});
});
})();