Conversaciones » Peticiones de scripts
Help: An Userscript to automatically copy urls on a page while loading
Something like this:
// ==UserScript==//
// @name Copy links
// @match http://mypage.com/index.php*
// @grant GM_setClipboard
// ==/UserScript==
GM_setClipboard(
[].map.call(
document.querySelectorAll('a[href*="https://serverhost.net/mylink/display?link="]'),
e => e.href
).join('\n')
);
However the real problem might be the site updating its pages dynamically after the userscript has been injected (so-called AJAX-site). In that case either wrap the code in setTimeout or use a sliding timer in a MutationObserver callback.
Thank you very much sir.
But, I feel the 'match' function should be replaced by something else, because there are some more pages apart from 'mypage.com' where it should be working.
Thanks again.
re: @match, you can declare it for as many sites as needed, see the docs
// @match https://www.example.com/*
// @match http://*.example.com/*
Help: An Userscript to automatically copy urls on a page while loading
Hi, I was trying to compose a script which will automatically copy all links pointing to https://serverhost.net/mylink/display?link=*
Illustration: Lets assume we are browsing http://mypage.com/index.php This page contains an html segment:
I want to copy all links that are pointing to https://serverhost.net/mylink/display?link=[variable string] available on this page.
I tried to use GM_setClipboard, but its not quite working for me. Please help.
Thanks.