forked from izneo-get/tampermonkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tiktokcounter_skip_timer.user.js
93 lines (82 loc) · 2.83 KB
/
tiktokcounter_skip_timer.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// ==UserScript==
// @name PSA Rips Skip Ads Timer
// @namespace http://tampermonkey.net/
// @version 0.6
// @description Modify TikTok Counter page content
// @author Darth Obvious
// @match https://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var cbtElement = document.getElementById('cbt');
if (!cbtElement || cbtElement.getAttribute('onclick') !== "formulaSend(event)") {
return;
}
function resetTimer(varName) {
window[varName] = 0;
}
function getVarName() {
var scripts = document.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
var script = scripts[i];
if (script.innerHTML.includes('window.wpSiteUrl = "')) {
var regex = /var (.+) = (\d+);/;
var match = script.innerHTML.match(regex);
if (match !== null) {
var variableName = match[1];
console.log(variableName);
return variableName;
}
}
}
return "";
}
// Add a "SKIP" button
function addSkipButton() {
var skipButton = document.createElement('button');
skipButton.id = 'skipButton';
skipButton.textContent = 'SKIP';
skipButton.style.position = 'fixed';
skipButton.style.top = '10px';
skipButton.style.left = '10px';
skipButton.style.zIndex = '9999';
skipButton.addEventListener('click', function() {
var varName = getVarName();
if (varName.length > 0) {
resetTimer(varName);
}
});
document.body.appendChild(skipButton);
}
function autoClickSkipButton() {
var skipButton = document.getElementById('skipButton');
if (skipButton) {
skipButton.click();
}
var continueButton = document.getElementById('cbt');
if (continueButton) {
if (typeof isHoverDone !== "undefined") {
isHoverDone = true;
}
if (typeof isTimerCompleted !== "undefined") {
isTimerCompleted = true;
}
if (typeof isAdClickDone !== "undefined") {
isAdClickDone = true;
}
if (typeof isClownClickDone !== "undefined") {
isClownClickDone = true;
}
if (typeof isFirstClickDone !== "undefined") {
isFirstClickDone = true;
}
continueButton.removeAttribute('disabled');
continueButton.setAttribute('type', 'submit');
continueButton.click();
//document.querySelector("#userForm").submit();
}
}
addSkipButton();
setInterval(autoClickSkipButton, 1000); // 1000 ms = 1 seconde
})();