您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Preview image when hover-over, generated by chatgpt by asking
// ==UserScript== // @name bangumi image preview // @namespace https://example.com // @version 0.1 // @description Preview image when hover-over, generated by chatgpt by asking // @match https://bgm.tv/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Function to convert image URLs function convertImageURL(url) { //const regex = /pic\/(crt|cover)\/(.*?)\?/; const regex = '\/\/lain\.bgm\.tv\/pic\/(.*)\/[a-z]\/(.*)'; const match = url.match(regex); console.log(`original url ${url}`) if (match) { console.log('matched'); const type = match[1]; const path = match[2]; console.log(match[0]) console.log(`type: ${match[1]}`) console.log(`path: ${match[2]}`) //const encodedPath = encodeURIComponent(path); const convertedURL = "//lain.bgm.tv/" + url.replace(match[0], `pic/${type}/l/${path}`); console.log(convertedURL) return convertedURL; } console.log('not matched') return url; } // Function to handle hover-over and rendering function handleHover(element) { const originalURL = element.getAttribute('src'); const convertedURL = convertImageURL(originalURL); // Create a div to display the converted image const hoverDiv = document.createElement('div'); hoverDiv.style.position = 'fixed'; hoverDiv.style.bottom = '10px'; hoverDiv.style.left = '10px'; hoverDiv.style.backgroundColor = 'white'; hoverDiv.style.padding = '10px'; hoverDiv.style.border = '1px solid black'; // Create an image element const image = document.createElement('img'); image.style.maxWidth = '400px'; // Adjust the maximum width as needed image.style.maxHeight = '400px'; // Adjust the maximum height as needed image.setAttribute('src', convertedURL); // Append the image element to the div hoverDiv.appendChild(image); // Append the div to the body document.body.appendChild(hoverDiv); // Remove the div when the mouse leaves the image element.addEventListener('mouseleave', () => { hoverDiv.remove(); }); } // Get all image elements on the page const images = document.querySelectorAll('img'); // Add hover-over event listener to each image images.forEach((image) => { console.log(image) image.addEventListener('mouseover', () => { handleHover(image); }); }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址