-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArchive.org Filter.user.js
More file actions
225 lines (192 loc) · 8.4 KB
/
Copy pathArchive.org Filter.user.js
File metadata and controls
225 lines (192 loc) · 8.4 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
// ==UserScript==
// @name Archive.org Filter
// @namespace psx_chd_filter
// @match *archive.org/download/*
// @include *archive.org/download/*
// @require https://code.jquery.com/jquery-3.6.0.min.js
// @grant none
// @version 1.1
// @author Andrea Do
// @description Advanced filter for Archive.org roms
// @license MIT
// ==/UserScript==
$(document).ready(function() {
var suffixes = `<input type="checkbox" id="use_suffix"> Use suffixes<br>
<div style="display: none;" id="display_boxes"><br>
<strong>Generic</strong><br>
<input type="checkbox" data-suffix="[a]" checked style="display: none;"> [a] Alternate<br>
<input type="checkbox" data-suffix="[p]" checked style="display: none;"> [p] Pirate<br>
<input type="checkbox" data-suffix="[b]" checked style="display: none;"> [b] Bad Dump (avoid these, they may not work!)<br>
<input type="checkbox" data-suffix="[t]" checked style="display: none;"> [t] Trained<br>
<input type="checkbox" data-suffix="[f]" checked style="display: none;"> [f] Fixed<br>
<input type="checkbox" data-suffix="[T-]" checked style="display: none;"> [T-] OldTranslation<br>
<input type="checkbox" data-suffix="[T+]" checked style="display: none;"> [T+] NewerTranslation<br>
<input type="checkbox" data-suffix="[h]" checked style="display: none;"> [h] Hack<br>
<input type="checkbox" data-suffix="[cr" checked style="display: none;"> [cr {x}] Cracked (by {x})<br>
<input type="checkbox" data-suffix="(-)" checked style="display: none;"> (-) Unknown Year<br>
<input type="checkbox" data-suffix="[o]" checked style="display: none;"> [o] Overdump<br>
<input type="checkbox" data-suffix="[!]" checked style="display: none;"> [!] Verified Good Dump<br>
<input type="checkbox" data-suffix="ZZZ_" checked style="display: none;"> ZZZ_ Unclassified<br>
<input type="checkbox" data-suffix="(Unl)" checked style="display: none;"> (Unl) Unlicensed<br><br>
<strong>Platform specific</strong><br>
<input type="checkbox" data-suffix="[PC10]" checked style="display: none;"> NES - [PC10] PlayChoice 10<br>
<input type="checkbox" data-suffix="[VS]" checked style="display: none;"> NES - [VS] Versus<br>
<input type="checkbox" data-suffix="[BS]" checked style="display: none;"> SNES - [BS] BS Roms<br>
<input type="checkbox" data-suffix="[SF]" checked style="display: none;"> SNES - [SF] Sufami Turbo<br>
<input type="checkbox" data-suffix="[NP]" checked style="display: none;"> SNES - [NP] Nintendo Power<br>
</div>`;
var download_all = '<div id="download_all"><b>Attempt bulk download</b> <i>(think thrice before doing this!)</i></div>';
var hide_demo = '<h3>Disc type</h3>Include demos: <input type="checkbox" checked id="demos"><br>Include multidisc: <input type="checkbox" checked id="multidisc"><br>';
var countries = '<h3>Localization</h3>Country/Region: <select id="country"><option value=".">ALL</option><option value="anything_else">Uncategorized</option></select><br>';
var size_limit = '<h3>Misc</h3>'+suffixes+'Size limit: <input style="max-width: 75px;" id="limit" type="number" placeholder="Size limit" value="50000">MB<div><span style="display: none;" id="stats"><h3>Stats</h3>Showing <span id="counter">0</span> file(s).<br>Total size: <span id="total_size">0</span>'+download_all+'</span></div>';
$("h1").after(hide_demo+countries+size_limit);
});
//waitForKeyElements("#total_size", actions);
function engine() {
$(document).ready(function() {
var country_list = ['Italy', 'France', 'Germany', 'Spain', 'Netherlands', 'Sweden', 'Denmark', 'Norway', 'Portugal', 'Japan', 'USA', 'Europe', 'UK'];
country_list.sort();
for(k=0; k < country_list.length; k++) {
$("#country").append('<option value="('+country_list[k]+')">'+country_list[k]+'</option>');
}
$("#download_all").append('<br><button id="dl_all">Download all</button>');
$("#dl_all").click(function() {
var exts = ['chd', 'zip', '7z', 'nes', 'sfc'];
var sels = "";
var selectors = "";
for(e=0; e < exts.length; e++) {
if(e==exts.length-1) {
sels+=".directory-listing-table [href$='."+exts[e]+"']:visible";
} else{
sels+=".directory-listing-table [href$='."+exts[e]+"']:visible, ";
}
}
selectors = sels;
var len = $(selectors).length;
if(len > 20) {
var ask = confirm("This will open "+len+" tabs! Are you sure?");
if(ask == true) {
$(selectors).each(function() {
var url = encodeURIComponent(window.location.href+"/"+$(this).attr("href"));
window.open(decodeURIComponent(url));
});
}
} else {
$(selectors).each(function() {
var url = encodeURIComponent(window.location.href+"/"+$(this).attr("href"));
window.open(decodeURIComponent(url));
});
}
});
$("input, select").click(function() {
var sum = 0;
$("#stats").show();
$("tr").show();
var exts = ['chd', 'zip', '7z', 'nes', 'sfc'];
var sels = "";
var selectors = "";
for(e=0; e < exts.length; e++) {
if(e==exts.length-1) {
sels+=".directory-listing-table [href$='."+exts[e]+"']:visible";
} else{
sels+=".directory-listing-table [href$='."+exts[e]+"']:visible, ";
}
}
selectors = sels;
// Filter countries
var country = $("#country option:selected").val();
if(country === "anything_else") {
for(k=0; k < country_list.length; k++) {
$(selectors).each(function() {
if($(this).text().indexOf(country_list[k]) > -1) {
$(this).closest("tr").hide();
} else {
$(this).closest("tr").show();
}
});
}
} else {
$(selectors).each(function() {
if($(this).text().indexOf(country) <= -1) {
$(this).closest("tr").hide();
} else {
$(this).closest("tr").show();
}
});
}
// Size limit
var limit = parseInt($("#limit").val());
var this_size = 0;
$("tr td:nth-child(3):visible").each(function() {
if($(this).text().indexOf("M") > -1) {
this_size = ($(this).text().split("M")[0]*1);
} else if($(this).text().indexOf("G") > -1) {
this_size = ($(this).text().split("G")[0]*1024);
} else if($(this).text().indexOf("K") > -1) {
this_size = ($(this).text().split("K")[0]*0.001);
}
if(this_size <= limit) {
$(this).closest("tr").show();
} else {
$(this).closest("tr").hide();
}
});
// Show demos
if($("#demos").is(':checked')) {
$("tr:visible").show();
} else {
$(selectors).each(function() {
if($(this).text().indexOf("(Demo)") > -1) {
$(this).closest("tr").hide();
}
});
}
// Show Multidisc
if($("#multidisc").is(':checked')) {
$("tr:visible").show();
} else {
$(selectors).each(function() {
if($(this).text().indexOf("(Disc ") > -1) {
$(this).closest("tr").hide();
}
});
}
// Suffixes
if($("#use_suffix").is(":checked")) {
$("[data-suffix]").show();
$("#display_boxes").show();
$(selectors).each(function() {
var this_rom = $(this);
$("[data-suffix]:checked").each(function() {
var attr = $(this).attr('data-suffix');
if(this_rom.text().indexOf(attr) > -1) {
this_rom.closest("tr").show();
return false;
} else {
this_rom.closest("tr").hide();
}
});
});
} else {
$("[data-suffix]").hide();
$("#display_boxes").hide();
}
// Extensions
// Sum
$("tr td:nth-child(3):visible").each(function() {
var this_size = 0;
var size_arr = [['M', 1], ['G', 1024], ['K', 0.001]];
for(s=0; s < size_arr.length; s++) {
if($(this).text().indexOf(size_arr[s][0]) > -1) {
this_size = $(this).text().split(size_arr[s][0])[0]*size_arr[s][1];
}
}
sum+=this_size;
});
// Stats
$("#counter").text($(selectors).length);
$("#total_size").text(sum.toFixed(2)+" MB ("+(sum/1024).toFixed(2)+" GB)");
});
});
}
engine();