This is an example what I would like to do. Whenever we are on target url i.e. stackoverflow to appear a sticky footer on the bottom with buttons. One of the buttons to type something in search, submit the form. After this it waits for page to load and do something the page that just loaded, i.e. click on the first link.
I found out this is not possible by just running a click after the submit because the frames of the page change or something like that, how would it be possible to do this with tampermonkey.
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://stackoverflow.com/
// @grant none
// ==/UserScript==
(function() {
'use strict';
$('body').append('<div id="test"><p><button onclick="myFunction()">Click me</button></p></div>');
$('body').append(
`<script type="text/javascript">
function myFunction() {
// page 1
document.querySelector('#search > div > input').value="tampermonkey";
document.forms[0].submit();
// page 2 (DOEST WORK)
document.querySelector('#question-summary-29592068 > div.summary > div.result-link > h3 > a');
}
</script>`
);
$('#test').css({'position': 'fixed',
'left': '0',
'bottom': '0',
'width': '100%',
'background-color': 'red',
'color': 'white',
'text-align': 'center',
'z-index':'1'
});
})();