Created
April 26, 2015 17:02
-
-
Save chylex/b91f4eff534a60f1c101 to your computer and use it in GitHub Desktop.
Greasemonkey script - OpenEye magic button (removes duplicates and unwanted reports)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name OpenEye tweaks | |
// @namespace http://chylex.com/ | |
// @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 | |
// @version 1 | |
// ==/UserScript== | |
var checkedCombinations = { // !! you will need to adjust these for your purposes | |
"java.lang.NullPointerException": [ | |
"cpw.mods.fml.client.FMLClientHandler.getCurrentLanguage()", | |
"net.minecraft.item.ItemStack.func_77960_j()", | |
"com.mumfrey.liteloader.launch.LiteLoaderTweaker$StartupState.gotoState()", | |
"madscience.client.ClientProxy.registerRenderingHandler()" | |
], | |
"java.lang.IllegalArgumentException": [ | |
"net.minecraft.enchantment.Enchantment.<init>()" | |
], | |
"java.lang.ArrayIndexOutOfBoundsException": [ | |
"codechicken.nei.IDConflictReporter.blockConstructed()" | |
], | |
"java.lang.RuntimeException": [ | |
"net.minecraftforge.common.Configuration.load()", | |
"mods.immibis.chunkloader.Fuels.setProperty()", | |
"chylex.hee.tileentity.TileEntityCustomSpawner.createLogic()" | |
], | |
"java.lang.NoClassDefFoundError": [ | |
"java.lang.Class.getDeclaredConstructors0()", | |
"java.lang.Class.forName0()" | |
], | |
"java.lang.ClassCastException": [ | |
"" | |
], | |
"cpw.mods.fml.common.LoaderException": [ | |
"cpw.mods.fml.common.LoadController.transition()" | |
] | |
}; | |
var maxModsInReport = 5; | |
// 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 class='btn btn-default' onclick='gmStartMagic()'>The magic button!</button> <span id='gmStatus' class='btn btn-default' style='opacity:0'></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.gmStartMagic = function(){ | |
processTable(); | |
$("#gmStatus").css("opacity","1"); | |
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){ | |
$("#gmStatus").text("Loading page "+id+"/"+total); | |
var _id = id; | |
var _total = total; | |
$.get("http://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 $("#gmStatus").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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment