Simply press the NumpadAdd hotkey on your selected term(s) in the search box and they will be auto-encased in quotes, using Google's "exact search" boolean syntax - no more tedious cursor positioning or unrelated search results.
目前為
// ==UserScript==
// @name Google & YouTube - Exact Search Hotkey
// @namespace GYESH
// @description Simply press the NumpadAdd hotkey on your selected term(s) in the search box and they will be auto-encased in quotes, using Google's "exact search" boolean syntax - no more tedious cursor positioning or unrelated search results.
// @match *://*/*
// @exclude https://www.google.ca/maps/*
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @author drhouse
// @icon https://www.google.ca/images/google_favicon_128.png
// @version 5.0
// @license CC-BY-NC-SA-4.0
// ==/UserScript==
/* global jQuery, $ */
(function() {
'use strict';
$(document).on('keydown', function(e) {
if (e.key === 'Add' || e.keyCode === 107) {
var activeElement = document.activeElement;
if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA') {
var start = activeElement.selectionStart;
var end = activeElement.selectionEnd;
var text = $(activeElement).val();
var selectedText = text.substring(start, end).trim();
var nQuote = text.substring(0, start) + '"' + selectedText + '"' + text.substring(end);
$(activeElement).val(nQuote);
e.preventDefault();
}
}
});
})();