-
Notifications
You must be signed in to change notification settings - Fork 4
/
AniDB random.user.js
38 lines (34 loc) · 1.23 KB
/
AniDB random.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
// ==UserScript==
// @name AniDB random
// @namespace 7nik
// @version 1.0
// @description Adds buttons to choose random anime in the wishlist
// @author You
// @match https://anidb.net/user/wishlist*
// @grant none
// ==/UserScript==
"use strict";
function randomAnime (ev) {
const type = ev.target.classList[1];
$("table.wishlist td.name a[style]").removeAttr("style");
const list = $(`table.wishlist tr.wishlist:has(a${type ? `.${type}` : ""})`);
const elem = list.eq(Math.floor(list.length * Math.random()));
elem.find(".name a").attr("style", "color:red !important;");
elem[0].scrollIntoView();
document.scrollingElement.scrollTop -= window.innerHeight / 2;
}
const div = document.createElement("div");
div.style.position = "fixed";
div.style.bottom = 0;
div.style.right = 0;
div.style.left = "auto";
div.style.backgroundColor = "#000B";
div.style.padding = "10px";
div.innerHTML = `
<span style="cursor:pointer">Random:</span>
<a class="i_icon i_pri_high" style="cursor:pointer"></a>
<a class="i_icon i_pri_med" style="cursor:pointer"></a>
<a class="i_icon i_pri_low" style="cursor:pointer"></a>
`;
div.addEventListener("click", randomAnime);
document.body.append(div);