Skip to content

Instantly share code, notes, and snippets.

@wyw
Last active December 14, 2018 11:16
Show Gist options
  • Save wyw/21a3f15ec4ee3c9cbf5386161052b0db to your computer and use it in GitHub Desktop.
Save wyw/21a3f15ec4ee3c9cbf5386161052b0db to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name PVE IP
// @namespace http://tampermonkey.net/
// @version 0.1
// @include https://*:8006/*
// ==/UserScript==
(function (i, s, o, g, r, c, a, m) {
i['global_clipboard'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; a.onload = c; m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js', 'ga', function onload() {
var reg = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/g;
var itv = null;
var list = [];
function handleClick(t) {
setTimeout(() => {
t.style.color = 'green';
}, 1000);
t.style.color = 'inherit';
return t.innerHTML.match(reg)[0];
}
function applyClipboard() {
var l = Array.from(document.querySelectorAll('label')).filter(i => i.textContent.match(reg))[0];
if (typeof l !== 'undefined') {
if (list.indexOf(l) === -1) {
list.push(l);
l.style.color = 'green';
new ClipboardJS(l, { text: handleClick});
return;
}
}
}
itv = setInterval(applyClipboard, 500);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment