forked from pvpoke/pvpoke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pvpokelmtlss.js
158 lines (140 loc) · 5.18 KB
/
pvpokelmtlss.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// ==UserScript==
// @name PVPokeLimitless
// @namespace http://tampermonkey.net/
// @version 0.5
// @description PVPokeLimitless Tapermonkey
// @author Chris
// @match *://pvpoke.com/*
// @grant GM.xmlHttpRequest
// @grant unsafeWindow
// @run-at document-start
// ==/UserScript==
(function () {
"use strict";
var url = window.location.href;
function SaveRankingButton() {
var customMetaSelector = new PokeMultiSelect($(".poke.multi").eq(0));
var data = GameMaster.getInstance().data;
customMetaSelector.init(data.pokemon, new Battle());
customMetaSelector.setPokemonList(metaGroupExport);
var cup = document.getElementsByClassName("format-select")[0];
cup = cup.options[cup.selectedIndex];
var cp = cup.value;
cup = cup.getAttribute("meta-group");
var category = document.getElementsByClassName("category-select")[0];
category = category.options[category.selectedIndex];
category = category.value;
customMetaSelector.saveCustomList(cp + cup + category, false);
}
function BlockScript(script) {
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.addedNodes.length) {
for (var i = 0; i < mutation.addedNodes.length; i++) {
var node = mutation.addedNodes[i];
if (node.tagName === "SCRIPT" && node.src.includes(script)) {
node.parentNode.removeChild(node);
}
}
}
});
});
observer.observe(document, { childList: true, subtree: true });
}
function LoadScript(scripturl) {
GM.xmlHttpRequest({
method: "GET",
url: scripturl,
onload: function (response) {
const script = document.createElement("script");
script.textContent = response.responseText;
document.head.appendChild(script);
},
onerror: function (error) {
console.error("Error loading script:", error);
},
});
}
if (url.includes("/new-season/rankings") || url.includes("/rankings")) {
BlockScript("Pokebox.js");
BlockScript("PokeMultiSelect.js");
BlockScript("RankingInterface.js");
LoadScript(
"https://raw.githubusercontent.com/chrisisth/pvpoke-limitless/master/src/js/interface/Pokebox.js"
);
LoadScript(
"https://raw.githubusercontent.com/chrisisth/pvpoke-limitless/master/src/js/interface/PokeMultiSelect.js"
);
LoadScript(
"https://raw.githubusercontent.com/chrisisth/pvpoke-limitless/master/src/js/interface/RankingInterface.js"
);
window.onload = function () {
var button = document.createElement("a");
button.className = "button";
button.textContent = "Save Rankings";
button.addEventListener("click", function () {
SaveRankingButton();
});
var exportButton = document.querySelector("a.download-csv");
if (exportButton) {
exportButton.parentNode.insertBefore(button, exportButton.nextSibling);
}
Main();
};
}
if (url.includes("/new-season/battle") || url.includes("/battle")) {
BlockScript("PokeMultiSelect.js");
BlockScript("RankingInterface.js");
LoadScript(
"https://raw.githubusercontent.com/chrisisth/pvpoke-limitless/master/src/js/interface/Pokebox.js"
);
LoadScript(
"https://raw.githubusercontent.com/chrisisth/pvpoke-limitless/master/src/js/interface/PokeMultiSelect.js"
);
window.onload = function () {
Main();
$(".poke-max-count").text("1000");
};
}
if (
url.includes("/new-season/team-builder") ||
url.includes("/team-builder")
) {
BlockScript("PokeMultiSelect.js");
BlockScript("RankingInterface.js");
LoadScript(
"https://raw.githubusercontent.com/chrisisth/pvpoke-limitless/master/src/js/interface/Pokebox.js"
);
LoadScript(
"https://raw.githubusercontent.com/chrisisth/pvpoke-limitless/master/src/js/interface/PokeMultiSelect.js"
);
window.onload = function () {
// Team Builder - team size = 3
var teamOption = document.querySelector(".team-option .team-size-select");
if (teamOption) {
var newOption = document.createElement("option");
newOption.value = "3";
newOption.textContent = "3";
teamOption.appendChild(newOption);
}
// Team Builder - scorecard increase
var scorecardSelect = document.querySelector(
".team-option .scorecard-length-select"
);
if (scorecardSelect) {
var values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000];
values.forEach(function (value) {
var option = document.createElement("option");
option.value = value;
option.textContent = value;
scorecardSelect.appendChild(option);
});
}
Main();
$(".custom-alternatives .poke-max-count").text("1000");
$(".custom-threats .poke-max-count").text("1000");
$(".exclude-alternatives .poke-max-count").text("1000");
$(".exclude-threats .poke-max-count").text("1000");
};
}
})();