-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LoadAllPages.user.js
133 lines (112 loc) · 4.48 KB
/
LoadAllPages.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
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
// ==UserScript==
// @name Load & Filter OpenEye Crashes
// @description Adds a button to load all pages in the 'Crashes' tab, and filter out unwanted crashes. Configurable at the beginning of the script.
// @version 1
// @license MPL-2.0
// @namespace https://chylex.com
// @homepageURL https://github.com/chylex/Userscripts
// @supportURL https://github.com/chylex/Userscripts/issues
// @include http://openeye.openmods.info/crashes
// @include https://openeye.openmods.info/crashes
// @include http://openeye.openmods.info/crashes?page=1
// @include https://openeye.openmods.info/crashes?page=1
// @run-at document-end
// ==/UserScript==
var checkedCombinations = {
// "java.lang.NullPointerException": [
// "cpw.mods.fml.client.FMLClientHandler.getCurrentLanguage()",
// "net.minecraft.item.ItemStack.func_77960_j()",
// "com.mumfrey.liteloader.launch.LiteLoaderTweaker$StartupState.gotoState()"
// ],
// "java.lang.RuntimeException": [
// "net.minecraftforge.common.Configuration.load()"
// ],
// "java.lang.NoClassDefFoundError": [
// "java.lang.Class.getDeclaredConstructors0()"
// ],
// "java.lang.ClassCastException": [
// ""
// ],
// "cpw.mods.fml.common.LoaderException": [
// "cpw.mods.fml.common.LoadController.transition()"
// ]
};
var maxModsInReport = 9000;
// handling
if (typeof $ == "undefined"){
var $ = unsafeWindow.jQuery;
}
var statDuplicates = 0;
var statUnwanted = 0;
var statTooManyMods = 0;
$(document).ready(function(){
var mainDiv = $("table").parent();
mainDiv.prepend("<button id='chylexButton' class='btn btn-default' onclick='chylexLoadAllPages()'>Load all pages</button> <span id='chylexStatus' class='btn btn-default' style='display:none'></span><br>");
$("th.col-md-2").css("width", "8%"); // Date
$("th.col-md-6").css("width", "8%"); // Note
$("th.col-md-1").css("width", "1%"); // Reports
unsafeWindow.chylexLoadAllPages = function(){
processTable();
$("#chylexButton").hide();
$("#chylexStatus").show();
var divClasses = $("ul.pagination:first").parent().attr("class").split(/\s+/), totalPages = 0;
for(var a = 0; a < divClasses.length; a++){
if (divClasses[a].indexOf("pages-") == 0){
totalPages = parseInt(divClasses[a].substring(6), 10);
break;
}
}
$("ul.pagination").each(function(){
$(this).remove();
});
loadPage(2, totalPages);
}
});
function processTable(){
var td, exceptionName, exceptionCode, exceptionCodeFull;
var stored = [];
$("tr").each(function(){
td = $($(this).children()[1]);
exceptionName = $(td.children()[0]).text();
exceptionCodeFull = td.text().trim().substring(exceptionName.length).trim();
exceptionCodeFull = exceptionCodeFull.substring(0, exceptionCodeFull.indexOf(" "));
exceptionCode = exceptionCodeFull.substring(0, exceptionCodeFull.indexOf(":") - 1);
if (stored.indexOf(exceptionName + exceptionCodeFull) >= 0){
$(this).remove();
++statDuplicates;
}
else if (shouldRemove(exceptionName, exceptionCode)){
$(this).remove();
++statUnwanted;
}
else if (td.children("span.label-primary").size() > maxModsInReport){
$(this).remove();
++statTooManyMods;
}
else{
stored.push(exceptionName + exceptionCodeFull);
}
});
}
function loadPage(id, total){
$("#chylexStatus").text("Loading page " + id + "/" + total);
var _id = id;
var _total = total;
$.get("https://openeye.openmods.info/crashes?page=" + id, function(data){
data = data.substring(data.indexOf("<tbody>") + 7).trim();
data = data.substring(0, data.indexOf("</tbody>")).trim();
$("tbody").append(data);
processTable();
if (_id < total){
loadPage(_id + 1, _total);
}
else{
$("#chylexStatus").text("All pages loaded! Removed " + statDuplicates + " duplicates, " + statUnwanted + " unwanted and " + statTooManyMods + " with too many mods!");
}
}).fail(function(){
alert("Failed fetching data from OpenEye.");
});
}
function shouldRemove(name, code){
return name in checkedCombinations && checkedCombinations[name].indexOf(code) >= 0;
}