您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Boosts productivity by letting you have selected text or links to instantly search or open
// ==UserScript== // @name DSG (Drag Search & Go) v1.7 // @namespace https://deeone.blog // @version 1.7 // @description Boosts productivity by letting you have selected text or links to instantly search or open // @author deoone // @match *://*/* // @grant GM_openInTab // ==/UserScript== (function() { 'use strict'; const SEARCH_BASE = 'https://www.google.com/search?q='; let isMouseDown = false; let startX, startY; let moved = false; let hadSelection = false; let startTarget = null; document.addEventListener('mousedown', e => { if (e.button !== 0) return; isMouseDown = true; moved = false; startX = e.clientX; startY = e.clientY; startTarget = e.target; hadSelection = !window.getSelection().isCollapsed; }); document.addEventListener('mousemove', e => { if (!isMouseDown || moved) return; const dx = e.clientX - startX; const dy = e.clientY - startY; if (Math.hypot(dx, dy) > 5) { moved = true; // considered a drag if movement exceeds 5px? } }); document.addEventListener('mouseup', e => { if (!isMouseDown) return; isMouseDown = false; if (!moved) return; // was trying to make it so it only works if i drag but seems like that doesnt work let url = null; const sel = window.getSelection().toString().trim(); if ((hadSelection || sel) && sel) { url = SEARCH_BASE + encodeURIComponent(sel); } else { // Otherwise, check if they dragged a link const link = e.target.closest('a') || (startTarget.closest && startTarget.closest('a')); if (link && link.href) { url = link.href; } } if (!url) return; // Handle how the URL is opened based on key modifiers if (e.ctrlKey && e.shiftKey) { // we use gm_openInTab to open a background tab, useful for saving tabs to look at later GM_openInTab(url, { active: false }); } else if (e.ctrlKey) { // redirect to current tab window.location.href = url; } else { // open in new tab but move to that tab GM_openInTab(url, { active: true }); } }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址