您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a button to convert Twitter image URLs to SauceNAO search URLs independently of other extensions or buttons and changes color when clicked
当前为
// ==UserScript== // @name Twitter Image to SauceNAO // @namespace http://yourwebsite.com // @version 1.5 // @description Adds a button to convert Twitter image URLs to SauceNAO search URLs independently of other extensions or buttons and changes color when clicked // @author FunkyJustin // @match https://twitter.com/* // @match https://x.com/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Add custom CSS for the button const style = document.createElement('style'); style.innerHTML = ` .saucenao-button { color: rgb(29, 155, 240); /* Twitter's default link color */ } .saucenao-button.clicked { color: rgb(255, 69, 0); /* Color after button is clicked */ } `; document.head.appendChild(style); function createSauceNAOButton(imageUrl) { const button = document.createElement('div'); button.className = 'saucenao-button'; button.style.display = 'inline-block'; button.style.marginLeft = '8px'; button.style.cursor = 'pointer'; button.innerText = 'SauceNAO'; button.addEventListener('click', (event) => { event.stopPropagation(); event.preventDefault(); const encodedUrl = encodeURIComponent(imageUrl); const saucenaoUrl = `https://saucenao.com/search.php?url=${encodedUrl}`; window.open(saucenaoUrl, '_blank'); button.classList.add('clicked'); }); return button; } function addSauceNAOButtons() { const images = document.querySelectorAll('img[src*="pbs.twimg.com/media"]'); images.forEach(image => { const container = image.closest('article')?.querySelector('div[role="group"]'); if (container) { const existingButton = container.querySelector('.saucenao-button'); if (!existingButton) { const sauceNAOButton = createSauceNAOButton(image.src); container.appendChild(sauceNAOButton); } } }); } const observer = new MutationObserver((mutations) => { mutations.forEach(() => { addSauceNAOButtons(); }); }); observer.observe(document.body, { childList: true, subtree: true }); addSauceNAOButtons(); })();