-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlike-love_shortkey.js
70 lines (59 loc) · 2.53 KB
/
like-love_shortkey.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
// ==UserScript==
// @name Pixiv Like-Love Shortkey
// @namespace https://github.com/MonoScyron/pixiv-scripts
// @version 1.2.5
// @description Links the "like" and "bookmark" button to alt-ctrl-s (Private bookmark). Links "like" only to ctrl-s.
// @author MonoScyron
// @updateURL https://raw.githubusercontent.com/MonoScyron/pixiv-scripts/main/like-love_shortkey.js
// @downloadURL https://raw.githubusercontent.com/MonoScyron/pixiv-scripts/main/like-love_shortkey.js
// @match https://www.pixiv.net/*/
// @match https://www.pixiv.net/*/users/*
// @match https://www.pixiv.net/*/artworks/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=pixiv.net
// @grant none
// @noframes
// ==/UserScript==
(function() {
'use strict';
if(document.body != null) {
document.body.addEventListener("keydown", onkeydown);
}
onkeydown = function(e) {
if(e.ctrlKey && e.altKey && e.key == 's') {
e.preventDefault();
likeWork();
var loveBtn = document.querySelector("button.gtm-main-bookmark");
if(loveBtn != null && loveBtn.getAttribute("disabled") == null) {
console.log("Accessing menu...");
document.querySelector("button.l6avS_e._1W1yk-M").click();
var del1 = setInterval(() => {
var loveBtnMenu = document.querySelector("li.sc-1o8nozx-2.bmbKoQ");
if(loveBtnMenu != null && loveBtnMenu.getAttribute("disabled") != "") {
console.log("Bookmarking work...");
clearInterval(del1);
loveBtnMenu.click();
var del2 = setInterval(() => {
var editBtn = document.querySelector("a.sc-d98f2c-0.sc-1ij5ui8-1.RICfj");
if(editBtn != null) {
console.log("Editing bookmark...");
clearInterval(del2);
editBtn.click();
}
}, 10);
}
}, 10);
}
}
else if(e.ctrlKey && e.key == 's') {
e.preventDefault();
likeWork();
}
}
function likeWork() {
var likeBtn = document.querySelector("button._35vRH4a");
if(likeBtn != null && likeBtn.getAttribute("disabled") == null) {
console.log("Liking work...");
likeBtn.click();
}
}
})();