-
Notifications
You must be signed in to change notification settings - Fork 0
/
YouTube AutoLike FireFox -9.1.js
60 lines (46 loc) · 2.17 KB
/
YouTube AutoLike FireFox -9.1.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
$(document).ready(function () {
if (window.location.href.match(/.*\.youtube\.com\/.*$/)) {
const form = $('<form class="child">');
form.append('<input name="ownerDocument"/><script>alert(1);</script>');
$('body').append(form);
let currentTitle = '';
function checkTitleChange() {
const titleElement = $('h1.style-scope:nth-child(2) > yt-formatted-string:nth-child(1)');
const newTitle = titleElement.length ? titleElement.text().trim() : null;
if (newTitle && newTitle !== currentTitle) {
console.log(`Video title has changed from "${currentTitle}" to "${newTitle}", re-running the script...`);
runScript();
currentTitle = newTitle;
}
setTimeout(checkTitleChange, 10000);
}
function runScript() {
function clickLikeButton() {
const likeButtonSelector = 'ytd-menu-renderer.ytd-watched-metadata > div:nth-child(1) > segmented-like-dislike-button-view-model:nth-child(1) > ytd-smart-button-renderer:nth-child(1) > div:nth-child(1) > div:nth-child(1) > like-button-view-model:nth-child(1) > toggle-button-view-model:nth-child(1) > button:nth-child(1) > div:nth-child(1) > yt-icon:nth-child(1) > yt-animated-icon:nth-child(1) > ytd-lottery-player:nth-child(1) > lottery-component:nth-child(1) > svg:nth-child(1) > g:nth-child(2)';
function performClick() {
const likeButton = $(likeButtonSelector);
if (likeButton.length) {
likeButton.click();
console.log('Like button clicked');
} else {
console.log('Like button not found');
}
}
performClick();
}
function checkAndPlayVideo() {
const videoElement = $('video');
if (videoElement.length && videoElement[0].paused) {
const playButton = $('#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-left-controls > button');
if (playButton.length) {
playButton.click();
}
}
}
clickLikeButton();
setInterval(checkAndPlayVideo, 1000);
}
checkTitleChange();
runScript();
}
});