您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
一個用來複製連結網址的userscript
- // ==UserScript==
- // @name Copy URL Link
- // @namespace https://github.com/nickburrows/userscript-copy-link
- // @description 一個用來複製連結網址的userscript
- // @match *://*/*
- // @inject-into content
- // @version 0.0.44
- // @author Nick Lin
- // @icon https://raw.githubusercontent.com/nickburrows/userscript-copy-link/e8f248af59bea72aeb08ded7743765ac1d6801ef/static/icon_32.png
- // @grant GM.setClipboard
- // @grant GM_setClipboard
- // ==/UserScript==
- (function () {
- 'use strict';
- window.addEventListener('load', () => {
- const evOpts = {
- capture: true,
- passive: true
- };
- let hoveredLink = null;
- const linkElements = document.getElementsByTagName('a');
- for (const link of linkElements) {
- link.addEventListener('mouseenter', () => {
- hoveredLink = link;
- }, evOpts);
- link.addEventListener('mouseleave', () => {
- hoveredLink = null;
- }, evOpts);
- }
- function eventKeyDown(ev) {
- if (hoveredLink && (ev.metaKey || ev.ctrlKey) && ev.key === 'c') {
- const linkUrl = hoveredLink.href;
- if (linkUrl !== null) {
- GM_setClipboard(linkUrl);
- }
- }
- }
- window.addEventListener('keydown', eventKeyDown, evOpts);
- });
- })();