Greasy Fork is available in English.

Discussioni » Richieste di creazione

Can the script track the timer, and perform an action (click on the button) when will be "0"?

§
Pubblicato: 19/03/2021
Modificato: 19/03/2021

Hi everyone.

On site has tasks with a countdown (20-600 seconds)
Can the script track the timer, and perform an action (click on the button) when will be "0"?
--
*Timer Code: ".time"

Script actions:

1) Click on the link to the task (https://site.ru/task/youtube/)

2) Click on the video to start it) * Built-in YouTube player

3) Track the timer with a countdown.

4) When on timer "0", perform the action. (click on the button: Get coins)

loop it.


Can someone give a sample code (for this action) ?
Thx

§
Pubblicato: 20/03/2021
Modificato: 20/03/2021

Yes that's possible.
If you don't give the link that has the youtube video nobody can really help you.

Basically the idea is

setInterval(function(){ //Starts the setInterval as soon as the page loaded
document.querySelector('Element that has the link').href.click(); //Click on the element that has the link

document.querySelector('Element that has the youtube link').click(); //Click on the element that has the youtube link

if(document.querySelector('Element that shows the timer number').innerText === '0')
{
document.querySelector('Element that has the coins').click(); //Click on the element that has the coins
}
}, 3000); //wait 3 secs to loop and run everything

§
Pubblicato: 21/03/2021

hacker09, thx!
---

But, unfortunately, I did not succeed did so that he fully worked .
Maybe it's all about the IDs I set.
-----

Here are the necessary parts of the page code:
---

< a href="https://ytmonster.ru/task/youtube/" data-track="notrack" target="_blank">MINI клиент

< div class="timer">< span class="time">34< /span>< /div>

< div class="butt">< input type="submit" onclick="window.close();" value="Получить coin и закрыть окно">< /div>

< iframe id="video-start" src="https://www.youtube.com/embed/iY93-9S7th0?enablejsapi=1&playerapiid=ytplayer&autoplay=0&controls=0"
-------

1) this is a link on the task

2) this is a timer

3) this is the confirmation button

4) this is the link of the embedded video.
----

I would be grateful if you can make the correct script.


************************************
Identifiers that I used:

1) ".panel-body .col-md-6 a" - Correct ID!
2) ".time" - Most likely incorrect ID
3) ".butt" - Most likely incorrect ID
4) ".video-start" - Most likely incorrect ID

§
Pubblicato: 21/03/2021

*I had to put spaces in the code, as part of the code was deleted when I left a message here.

§
Pubblicato: 22/03/2021
Modificato: 22/03/2021

That doesn't help, please share the website link here.
Or copy and paste the whole website html (CTRL+U) here www.pastebin.com

§
Pubblicato: 23/03/2021

OK.
https://pastebin.com/Rg6PdgWT

Uppe.ru [ytmonster.ru] - YT Views

§
Pubblicato: 23/03/2021

screenshot

§
Pubblicato: 24/03/2021

// ==UserScript==
// @name Click on get coins
// @namespace Click on get coins
// @version 0.1
// @description Click on get coins!
// @author hacker09
// @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

document.querySelector('.panel-body .col-md-6 a').href.click(); //Click on the element that has the link

if(document.querySelector("div.timer > span").innerText.innerText === '0')
{
document.querySelector("div.butt").click(); //Click on the element that has the coins
}
}, 3000); //wait 3 secs to loop and run everything
})();

§
Pubblicato: 24/03/2021

I doubt that you really sent me the whole website html... So this wasn't really helpful either. At least I couldn't find the element '.panel-body .col-md-6 a' that you said that is correct...

But now you got the main idea

Pubblica risposta

Accedi per pubblicare una risposta.