您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Middle clicking the search on Xhamster serach icon opens the results in a new tab. use library "wait-for-elements.js by Broke Adams
当前为
// ==UserScript== // @name Xhamster Middle Click Search (fork of "Youtube Middle Click Search" by Adrien Pyke // @namespace https://greasyfork.org/fr/users/7434-janvier56 // @version 1.0.0 // @description Middle clicking the search on Xhamster serach icon opens the results in a new tab. use library "wait-for-elements.js by Broke Adams // @author janvier57 // @author Adrien Pyke // @include https://xhamster.com/* // @require https://gitcdn.link/repo/fuzetsu/userscripts/b38eabf72c20fa3cf7da84ecd2cefe0d4a2116be/wait-for-elements/wait-for-elements.js // @grant GM_openInTab // ==/UserScript== (function () { 'use strict'; const SCRIPT_NAME = 'YMCS'; const Util = { log(...args) { args.unshift(`%c${SCRIPT_NAME}:`, 'font-weight: bold;color: #233c7b;'); console.log(...args); }, q(query, context = document) { return context.querySelector(query); }, qq(query, context = document) { return Array.from(context.querySelectorAll(query)); }, getQueryParameter(name, url = window.location.href) { name = name.replace(/[[\]]/gu, '\\$&'); const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`, 'u'), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/gu, ' ')); }, encodeURIWithPlus(string) { return encodeURIComponent(string).replace(/%20/gu, '+'); } }; waitForElems({ // sel: '#search-icon-legacy', //XHAM sel: '.search-submit', stop: true, onmatch(btn) { btn.onmousedown = function (e) { if (e.button === 1) { e.preventDefault(); } }; btn.onclick = function (e) { e.preventDefault(); e.stopImmediatePropagation(); // const input = Util.q('input#search').value.trim(); // XHAM const input = Util.q('input.search-text').value.trim(); if (!input) return false; // const url = `${location.origin}/results?search_query=${Util.encodeURIWithPlus(input)}`; // XHAM const url = `${location.origin}/search/${Util.encodeURIWithPlus(input)}`; if (e.button === 1) { GM_openInTab(url, true); } else if (e.button === 0) { window.location.href = url; } return false; }; btn.onauxclick = btn.onclick; } }); waitForElems({ sel: '.sbsb_c', onmatch(result) { result.onclick = function (e) { if (!e.target.classList.contains('sbsb_i')) { const search = Util.q('.sbpqs_a, .sbqs_c', result).textContent; const url = `${location.origin}/search/${Util.encodeURIWithPlus(search)}`; if (e.button === 1) { GM_openInTab(url, true); } else if (e.button === 0) { window.location.href = url; } } else if (e.button === 1) { // prevent opening in new tab if they middle click the remove button e.preventDefault(); e.stopImmediatePropagation(); } }; result.onauxclick = result.onclick; } }); })();