您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a floating button to copy the current page's title and URL
当前为
// ==UserScript== // @name Copy URL and Title // @namespace http://tampermonkey.net/ // @version 1.0 // @description Adds a floating button to copy the current page's title and URL // @match *://*/* // @grant GM_setClipboard // @license GPL-3.0 // ==/UserScript== (function() { 'use strict'; // Create floating button const button = document.createElement('div'); button.innerHTML = '📋'; button.style.cssText = ` position: fixed; bottom: 20px; right: 20px; width: 50px; height: 50px; background-color: #4CAF50; color: white; border-radius: 50%; text-align: center; line-height: 50px; font-size: 24px; cursor: pointer; z-index: 9999; box-shadow: 0 2px 5px rgba(0,0,0,0.3); `; // Create popup const popup = document.createElement('div'); popup.style.cssText = ` position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: white; padding: 20px; border-radius: 5px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); z-index: 10000; display: none; `; // Add button and popup to the page document.body.appendChild(button); document.body.appendChild(popup); // Button click event button.addEventListener('click', function() { const pageTitle = document.title; const pageUrl = window.location.href; const copyText = `${pageTitle}\n${pageUrl}`; // Copy to clipboard GM_setClipboard(copyText, 'text'); // Show popup popup.innerHTML = ` <h3>Copied to clipboard:</h3> <p><strong>Title:</strong> ${pageTitle}</p> <p><strong>URL:</strong> ${pageUrl}</p> <button id="closePopup" style="margin-top: 10px;">Close</button> `; popup.style.display = 'block'; // Close popup button document.getElementById('closePopup').addEventListener('click', function() { popup.style.display = 'none'; }); }); })();