您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Middle clicking the search on youtube opens the results in a new tab
当前为
// ==UserScript== // @name Youtube Middle Click Search // @version 1.3.10 // @description Middle clicking the search on youtube opens the results in a new tab // @match *://www.youtube.com/* // @require https://greatest.deepsurf.us/scripts/5679-wait-for-elements/code/Wait%20For%20Elements.js?version=122976 // @namespace https://greatest.deepsurf.us/users/649 // @grant GM_openInTab // ==/UserScript== console.log('started YMCS'); var process = function(element) { console.log('found search button'); // setup references var oldButton = document.querySelector("#search-btn"), button = document.createElement('button'), input = document.querySelector('#masthead-search-term'), initSearch = input.value.trim(); // imitate old button style button.appendChild(oldButton.firstChild.cloneNode(true)); button.firstChild.style.margin = '0 25px'; button.style.padding = '0'; button.className = oldButton.className; button.setAttribute('type', 'button'); // insert new button and remove old oldButton.parentNode.insertBefore(button, oldButton); oldButton.remove(); // bind events button.addEventListener('mousedown', function(e) { if(e.button === 1) { e.preventDefault(); } }, false); document.addEventListener('click', function(e) { if(button.isEqualNode(e.target)) { e.preventDefault(); if (input.value.trim() === '' || input.value.trim() === initSearch && e.button !== 1) return false; var url = location.origin + '/results?search_query=' + encodeURIComponent(input.value); if(e.button === 1) { console.log('opening'); GM_openInTab(url, true); } else if(e.button === 0) { window.location.href = url; } return false; } }); }; waitForElems('#search-btn', process, true);