js-tampermonkey-public-scripts/Intra - Меню.user.js
Unkas Amanjolov 42b29defae first commit
2024-10-07 10:25:50 +05:00

60 lines
1.8 KiB
JavaScript

// ==UserScript==
// @name Intra - Меню
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://online.inter-s.kz/apex/f?p=109*
// @icon https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://online.lse.kz&size=128
// @grant GM_registerMenuCommand
// @grant GM_setClipboard
// @grant GM.setClipboard
// ==/UserScript==
console.log ("Меню интегрирован");
GM_registerMenuCommand ("Копировать в буфер", start_to_clipboard);
function start_to_clipboard () {
console.log("Начало");
var elements = document.querySelectorAll('[id^="P2_EMP_BIRTHDAY_DISPLAY"]');
var default_ipenl_text = elements[0];
var textToCopy = default_ipenl_text.textContent.trim();
var targetId = "_hiddenCopyText_";
var target = document.getElementById(targetId);
if (!target) {
target = document.createElement("textarea");
target.style.position = "absolute";
target.style.left = "-9999px";
target.style.top = "0";
target.id = targetId;
document.body.appendChild(target);
}
target.textContent = textToCopy;
// select the content
var currentFocus = document.activeElement;
target.focus();
target.setSelectionRange(0, target.value.length);
// copy the selection
var succeed;
try {
succeed = document.execCommand("copy");
} catch(e) {
succeed = false;
}
// restore original focus
if (currentFocus && typeof currentFocus.focus === "function") {
currentFocus.focus();
}
// clear temporary content
target.textContent = "";
console.log("Конец");
}