Skip to content

Instantly share code, notes, and snippets.

@Ranamzes
Last active May 30, 2023 15:23
Show Gist options
  • Save Ranamzes/462f056ac42f571cdf38416bbe838ff5 to your computer and use it in GitHub Desktop.
Save Ranamzes/462f056ac42f571cdf38416bbe838ff5 to your computer and use it in GitHub Desktop.
Tampermonkey. Quick search from the clipboard with alt+V
// ==UserScript==
// @name Yandex image alt+V find from buffer
// @namespace https://gist.github.com/Ranamzes/462f056ac42f571cdf38416bbe838ff5.js
// @version 0.1
// @description Quick search from the clipboard with alt+V
// @author RE•MART
// @match https://yandex.ru/images/search*
// @icon https://www.google.com/s2/favicons?sz=64&domain=yandex.ru
// @grant none
// @run-at document-start
// @downloadURL https://gist.github.com/Ranamzes/462f056ac42f571cdf38416bbe838ff5/raw/2a7fc64487f410da5b969a18c0ea4ad0efb43727/easyFindYandexImage.user.js
// @updateURL https://gist.github.com/Ranamzes/462f056ac42f571cdf38416bbe838ff5/raw/easyFindYandexImage.user.js
// ==/UserScript==
(function() {
'use strict';
document.addEventListener('keydown', async function(event) {
if (event.altKey && event.key === 'v') {
event.preventDefault();
const startInput = document.querySelector('input[id^="uniq"]');
if (startInput) {
startInput.focus();
const text = await navigator.clipboard.readText();
startInput.value = text; // Set the input field value
startInput.dispatchEvent(new Event('input', { bubbles: true })); // Dispatch an 'input' event
// Simulate click on .websearch-button
const searchButton = document.querySelector('.websearch-button');
if (searchButton) {
searchButton.click();
}
}
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment