/
index.html
136 lines (120 loc) · 4.65 KB
/
index.html
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
---
layout: default
title: SID For Shiny
permalink: /tools/sid-for-shiny/
---
<h1>SID-For-Shiny</h1>
<hr />
<label for="pid">PID to make Shiny:</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text edited-border text-light" id="hexadecimal">0x</span>
</div>
<input type="text" class="form-control bg-dark text-light" id="pid" aria-describedby="hexadecimal">
</div>
<label for="tid">TID:</label>
<div class="input-group mb-3">
<input type="text" class="form-control bg-dark text-light" id="tid">
</div>
<hr />
<br />
<div class="alert alert-warning d-flex align-items-center d-none" role="alert" id="invalid-entry">
<svg class="bi flex-shrink-0 me-2" width="24" height="24" role="img" aria-label="Danger:">
<symbol id="exclamation-triangle-fill" fill="currentColor" viewBox="0 0 16 16">
<path
d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z" />
</symbol>
<use xlink:href="#exclamation-triangle-fill" />
</svg>
<div id="warning-content"></div>
</div>
<div class="d-grid gap-2">
<button type="button" class="btn btn-outline-warning" onclick="calculate()">Calculate!</button>
</div>
<div class="modal fade" id="resultsModal" tabindex="-1" aria-labelledby="resultsModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content bg-dark">
<div class="modal-header">
<h5 class="modal-title" id="resultsModalLabel"></h5>
<button type="button" class="btn-close bg-secondary" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="results"></div>
<div class="modal-footer">
<button id="close" type="button" class="btn btn-outline-warning" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var pids = [
"BEEFCAFE", "1337", "B00B1E5", "69696969", "DEADC0DE", "DEC0DE", "FEA51B1E", "1501A7ED",
"0B5E55ED", "5EED1E55", "50C1AB1E", "AAAAAAAA", "BADD1E", "BA11AD", "BA5EBA11", "BEE",
];
$("#pid").attr("placeholder", pids[~~(pids.length * Math.random())].padStart(8, "0"));
$("#tid").attr("placeholder", (~~(65536 * Math.random()) + "").padStart(5, "0"));
function calculate() {
var pid = $("#pid").val();
var tid = $("#tid").val();
var decPid = parseInt(pid, 16);
var decTid = parseInt(tid);
if (isNaN(decPid)) {
$("#invalid-entry").removeClass("d-none");
$("#warning-content").text("Invalid PID: Unable to coerce \"" + pid + "\" as a Hex string!");
return;
}
if (isNaN(decTid)) {
$("#invalid-entry").removeClass("d-none");
$("#warning-content").text("Invalid TID: Unable to coerce \"" + tid + "\" as a decimal!");
return;
}
if (decPid < 0 || decPid > 0xFFFFFFFF) {
$("#invalid-entry").removeClass("d-none");
$("#warning-content").text("Invalid PID: \"" + pid + "\" is not between 0 and 0xFFFFFFFF!");
return;
}
if (decTid < 0 || decTid > 65535) {
$("#invalid-entry").removeClass("d-none");
$("#warning-content").text("Invalid TID: \"" + tid + "\" is not between 0 and 65535!");
return;
}
$("#invalid-entry").addClass("d-none");
var pid16High = decPid >>> 16;
var pid16Low = decPid & 0xFFFF;
var square = pid16High ^ pid16Low ^ decTid;
var rangeLow = 8 * Math.floor(square / 8);
$("#resultsModalLabel").text(
"PID: 0x" + (pid + "").toUpperCase().padStart(8, "0") + " | TID: " + (tid + "").padStart(5, "0")
);
$("#results").html(
"<div>SID range for shiny: " + (rangeLow + "").padStart(5, "0") + " - " +
(rangeLow + 7 + "").padStart(5, "0") + "</div><div>SID to force square shiny: " +
(square + "").padStart(5, "0") + "</div>"
);
$('#resultsModal').modal("show");
setTimeout(function() {
$("#close").focus();
}, 200);
}
$("#pid").bind("keyup keydown", function() {
var testArr = $("#pid").val().split("");
var resultArr = [];
var isHex = new RegExp("[a-fA-F0-9]+")
for (var i in testArr) {
if (isHex.test(testArr[i]) && i < 8) {
resultArr.push(testArr[i]);
}
}
$("#pid").val(resultArr.join(""));
});
$("#tid").bind("keyup keydown", function() {
var testArr = $("#tid").val().split("");
var resultArr = [];
var isNum = new RegExp("[0-9]+")
for (var i in testArr) {
if (isNum.test(testArr[i]) && i < 5) {
resultArr.push(testArr[i]);
}
}
$("#tid").val(resultArr.join(""));
});
</script>