您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Enables site search for Arc browser and others using shortcuts
// ==UserScript== // @name Site Search for Arc Browser // @namespace http://tampermonkey.net/ // @version 0.1 // @description Enables site search for Arc browser and others using shortcuts // @author Faisal Bhuiyan // @match *://*/* // @grant none // @run-at document-start // @noframes // @license MIT // ==/UserScript== (function() { 'use strict'; const start = performance.now(); // List of search engines with their shortcuts and URLs // NOTE: Avoid adding your browser's default search engine to prevent redirect loops const searchEngines = [ { shortcut: '@perplexity', url: 'https://perplexity.ai/search?q=%s' }, { shortcut: '@g', url: 'https://www.google.com/search?q=%s' }, { shortcut: '@youtube', url: 'https://www.youtube.com/results?search_query=%s' }, { shortcut: '@morphic', url: 'https://morphic.sh/search?q=%s' }, { shortcut: '@qwant', url: 'https://www.qwant.com/?q=%s' }, { shortcut: '@phind', url: 'https://www.phind.com/search?q=%s' }, { shortcut: '@yandex', url: 'https://yandex.com/search/?text=%s' } ]; // Fast hostname check using Set for O(1) lookup // NOTE: These domains should match the search engines above, excluding your default search engine const searchDomains = new Set([ 'perplexity.ai', 'google.com', 'youtube.com', 'morphic.sh', 'qwant.com', 'phind.com', 'yandex.com' ]); const hostname = location.hostname; // Exit immediately if we're on a search engine if ([...searchDomains].some(domain => hostname.includes(domain))) return; // Get query parameters fast const params = new URLSearchParams(window.location.search); const query = params.get('q') || params.get('search_query') || params.get('text'); if (!query) return; const trimmedQuery = query.trim(); // Fast lookup using Array.find const engine = searchEngines.find(e => trimmedQuery.startsWith(e.shortcut)); if (engine) { const searchQuery = trimmedQuery.replace(engine.shortcut, '').trim(); if (searchQuery) { // Stop the page load as early as possible if (window.stop) window.stop(); // Try to prevent any further resource loading document.documentElement.innerHTML = ''; // Use the fastest redirection method const redirectUrl = engine.url.replace('%s', encodeURIComponent(searchQuery)); location.replace(redirectUrl); // Prevent any further script execution throw new Error('REDIRECT_COMPLETE'); } } const end = performance.now(); console.debug(`Arc Search executed in ${end - start}ms`); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址