I want to be able to click on certain text on specific sites and have it selected and copied to keyboard. So far I use something like this to select the text within specific classes using Stylus.
.classname {
user-select: all;
}
How can I have it copied to keyboard too? Trying this for IATE did work on selecting the string but did not work on copying (clicking on any of the translations there).
// ==UserScript==
// @name Iate select
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://iate.europa.eu/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
'use strict';
let style = document.createElement('style');
style.innerHTML = 'app-iate-search-term-refine{ user-select: all !important; }';
document.body.appendChild(style);
const element = document.querySelector('app-iate-search-term-refine');
element.addEventListener('click', () => {
const text = element.textContent;
GM_setClipboard(text);
});
})();