Previous script:
---
// ==UserScript==
// @name Uppe Task!
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Uppe Task!
// @author You
// @match https://uppe.ru/*
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
var YTparts = document.querySelector("#video-start").src.split('autoplay='); //Get the youtube link and split into parts
var YTPart1 = YTparts[0]; //Get the first yt link part
var YTPart2 = YTparts[1].replaceAll('0', '1'); //Get the second yt link part and replace all yt link yt parameters from 0 to 1
var FullNEWYTLink = YTPart1+'autoplay='+YTPart2; //Join all our modified parts
document.querySelector("#video-start").src = FullNEWYTLink; //Make the iframe have our modified yt link instead of the default yt link
setInterval(function(){ //Starts the setInterval as soon as the page loaded
if(document.querySelector("div.timer > span").innerText === '0')
{
document.querySelector("div.butt").click(); //Click on the element that has the coins
}
}, 3000); //wait 3 secs to loop and run everything
})();
No that isn't the problem
document.querySelector("div.butt")
and
document.querySelector("#video-start")
Aren't the problem either.
The only think I can think about is delay the script more using a settimeout to run it after a couple secs that the page loaded or wrapping everything inside window.location =
The script should be working as it is, just make sure you disable other extensions and scripts when you open that website, maybe something new you installed is crashing it? I don't know...
You could perform a simple test like
// ==UserScript==
// @name Uppe Task!
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Uppe Task!
// @author You
// @match https://uppe.ru/*
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
setInterval(function(){ //Starts the setInterval as soon as the page loaded
if(document.querySelector("div.timer > span").innerText === '0')
{
document.title = 'test succeeded'; //Change the tab title if the script worked
}
}, 3000); //wait 3 secs to loop and run everything
})();
You could perform a simple test like
// ==UserScript==
// @name Uppe Task!
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Uppe Task!
// @author You
// @match https://uppe.ru/*
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
setInterval(function(){ //Starts the setInterval as soon as the page loaded
if(document.querySelector("div.timer > span").innerText === '0')
{
document.title = 'test succeeded'; //Change the tab title if the script worked
}
}, 3000); //wait 3 secs to loop and run everything
})();
test succeeded
So I guess a delay isn't needed
The script should be working as it is, just make sure you disable other extensions and scripts when you open that website, maybe something new you installed is crashing it? I don't know...
Maybe the problem is somewhere on this part of the code?
var YTparts = document.querySelector("#video-start").src.split('autoplay='); //Get the youtube link and split into parts
var YTPart1 = YTparts[0]; //Get the first yt link part
var YTPart2 = YTparts[1].replaceAll('0', '1'); //Get the second yt link part and replace all yt link yt parameters from 0 to 1
var FullNEWYTLink = YTPart1+'autoplay='+YTPart2; //Join all our modified parts
document.querySelector("#video-start").src = FullNEWYTLink; //Make the iframe have our modified yt link instead of the default yt link
Test it again now
// ==UserScript==
// @name Uppe Task!
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Uppe Task!
// @author You
// @match https://uppe.ru/*
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
var YTparts = document.querySelector("#video-start").src.split('autoplay='); //Get the youtube link and split into parts
var YTPart1 = YTparts[0]; //Get the first yt link part
var YTPart2 = YTparts[1].replaceAll('0', '1'); //Get the second yt link part and replace all yt link yt parameters from 0 to 1
var FullNEWYTLink = YTPart1+'autoplay='+YTPart2; //Join all our modified parts
document.querySelector("#video-start").src = FullNEWYTLink; //Make the iframe have our modified yt link instead of the default yt link
setInterval(function(){ //Starts the setInterval as soon as the page loaded
if(document.querySelector("div.timer > span").innerText === '0')
{
document.title = 'test succeeded'; //Change the tab title if the script worked
}
}, 3000); //wait 3 secs to loop and run everything
})();
Problem in: document.querySelector("div.butt").click();
--
I replaced it on: window.top.close();
And the script performed all the steps.
--
But I do not know how to correctly compose the code for the button.
----
< div class="butt" >< input type="submit" onclick="window.close();" value="Получить coin" >< /div >
Test it again now
// ==UserScript==
// @name Uppe Task!
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Uppe Task!
// @author You
// @match https://uppe.ru/*
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
var YTparts = document.querySelector("#video-start").src.split('autoplay='); //Get the youtube link and split into parts
var YTPart1 = YTparts[0]; //Get the first yt link part
var YTPart2 = YTparts[1].replaceAll('0', '1'); //Get the second yt link part and replace all yt link yt parameters from 0 to 1
var FullNEWYTLink = YTPart1+'autoplay='+YTPart2; //Join all our modified parts
document.querySelector("#video-start").src = FullNEWYTLink; //Make the iframe have our modified yt link instead of the default yt link
setInterval(function(){ //Starts the setInterval as soon as the page loaded
if(document.querySelector("div.timer > span").innerText === '0')
{
document.title = 'test succeeded'; //Change the tab title if the script worked
}
}, 3000); //wait 3 secs to loop and run everything
})();
test succeeded
Was the window closed?
The only way to click on things is using .click(); after document.querySelector("whatever")
You can try submitting the form instead of clicking on the button that submits the form.
Try pasting in the console
document.querySelectorAll("form")
get the correct number then use the number like this
document.querySelectorAll("form")[0]
document.querySelectorAll("form")[1]
document.querySelectorAll("form")[2]
etc...
Then replace
document.querySelector("div.butt").click();
with
document.querySelectorAll("form")[1].submit(); //Change 1 to the correct number
in the original code
ok. I found the desired button code in the list of colors for buttons. (as strange as it would be) :)
*document.querySelector(".butt input").click();
---
Now everything works!
Anyway, thank you!
Perform an action if on the timer will be "0"
Before:
< div class="timer" >< span class="time" >231< /span >< /div >
After:
< div class="timer" style="display: none;" >< span class="time" >0< /span >< /div >
---
And then:
--
{
document.querySelector("div.butt").click();
}
}, 3000);
})();
---
WebSite HTML: https://pastebin.com/2i9DfNxk
https://greasyfork.org/ru/discussions/requests/79160
Unfortunately, this script does not work.
Perhaps the problem in: ("div.timer > span")
Thx.