Greasy Fork 支持简体中文。

Youtube Middle Click Search

Middle clicking the search on youtube opens the results in a new tab

目前為 2014-10-29 提交的版本,檢視 最新版本

// ==UserScript==
// @name       Youtube Middle Click Search
// @version    1.2
// @description  Middle clicking the search on youtube opens the results in a new tab
// @include      http*://www.youtube.com*
// @namespace https://greasyfork.org/users/649
// ==/UserScript==

var button = document.querySelector("#search-btn"),
    input = document.querySelector('#masthead-search-term'),
    form = document.querySelector('#masthead-search');
button.removeAttribute("onclick");
button.onclick = function(e) {
    e.preventDefault();
    if (input.value.trim() === '') return false;
    form.removeAttribute('target');
    if (e.which === 2) form.setAttribute('target', '_blank');
    form.submit();
    return false;
};