NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name oc2 unfuck
// @namespace http://tampermonkey.net/
// @version 0.9.2
// @description try to take over the world!
// @author You
// @include *torn.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @require https://gist.githubusercontent.com/BrockA/2625891/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js
// @require https://cdnjs.cloudflare.com/ajax/libs/tinysort/3.2.8/tinysort.min.js
// @grant GM.xmlHttpRequest
// @license MIT
// ==/UserScript==
var members = []
var activeMembers = []
var blehTarget = $('body')[0];
var blehConfig = { attributes: false, childList: true, characterData: false, subtree: true };
var bleh = new MutationObserver(function(mutations) {
if(document.getElementById('faction-crimes-root').length != 0){
bleh.disconnect();
var crimeTarget = $('div[id^="faction-crimes-root"]')[0];
var crimeConfig = { attributes: false, childList: true, characterData: false, subtree: true };
var crime = new MutationObserver(function(mutations) {
$.each(mutations, function(i, v){
if(mutations[i].addedNodes.length == 1 && typeof(mutations[i].addedNodes[0].className) == 'string' && mutations[i].addedNodes[0].className.indexOf('wrapper') >= 0){
if($('div[class*="buttonsContainer"]').find(":contains('Completed')")[0].className.indexOf('active') >= 0){
$(mutations[i].addedNodes).find('[class*="phase"]').find('[class*="title"]').detach().insertBefore($(mutations[i].addedNodes).find('[class*="panelBody"]'));
$(mutations[i].addedNodes).find('[class*="reward_"]').detach().insertBefore($(mutations[i].addedNodes).find('[class*="panelBody"]'));
$('[class*="rewardContainer_"]').hide()
$('[class*="scenario_"]').find('[class*="panel_"]').parent().attr('style', 'min-height: 0px !important')
$('[class*="phase_"]').parent().hide()
$('[class*="description_"]').hide()
tinysort($('[class*="scenario_"]').parent(), {selector:'[class*=levelValue_]', order:'desc'});
}else{
if($(mutations[i].addedNodes).find('[class*="iconContainer_"]')[0].className.indexOf('active_') >= 0 || $(mutations[i].addedNodes).find('[class*="iconContainer_"]')[0].className.indexOf('recruiting_') >= 0){
$(mutations[i].addedNodes).find('[class*="phase"]').find('[class*="title"]').attr('style', 'color: #84f1ff').detach().insertBefore($(mutations[i].addedNodes).find('[class*="panelBody"]'));
}
else if($(mutations[i].addedNodes).find('[class*="iconContainer_"]')[0].className.indexOf('expiring_') >= 0 || $(mutations[i].addedNodes).find('[class*="iconContainer_"]')[0].className.indexOf('paused_')){
$(mutations[i].addedNodes).find('[class*="phase"]').find('[class*="title"]').attr('style', 'color: #f7c327').detach().insertBefore($(mutations[i].addedNodes).find('[class*="panelBody"]'));
}
$('[class*="scenario_"]').find('[class*="panel_"]').parent().attr('style', 'min-height: 0px !important');
$('[class*="phase_"]').parent().hide()
$('[class*="description_"]').hide()
setTimeout(() => {
tinysort($('[class*="scenario_"]').parent(), {selector:'[class*=levelValue_]', order:'desc'}, {selector:'[class*=panel_] [class*=title_]', order:'asc', natural:true});
}, 100);
}
}
})
})
crime.observe(crimeTarget, crimeConfig);
}
})
bleh.observe(blehTarget, blehConfig);
$('body').on('click', $('div[class*="scenario_"]'), function(event) {
if($(event.target)[0].classList.value.indexOf('panel_') >= 0){
$($(event.target)[0].offsetParent).find($('[class*="phase_"]')).parent().toggle()
$($(event.target)[0].offsetParent).find($('[class*="description_"]')).toggle()
$($(event.target)[0].offsetParent).find('[class*="animation_"]').toggle()
if($($(event.target)[0].offsetParent).find($('[class*="description_"]'))[0].attributes[1].nodeValue.indexOf('block') >= 0){
$($(event.target)[0].offsetParent).find('[class*="panel"]').find('[class*="title"]').detach().appendTo($($(event.target)[0].offsetParent).find('[class*="phase"]'));
$($(event.target)[0].offsetParent).find('[class*="reward_"]').detach().prependTo($($(event.target)[0].offsetParent).find('[class*="rewardContainer_"]'));
$($(event.target)[0].offsetParent).find($('[class*="rewardContainer_"]')).show()
if($($(event.target)[0].offsetParent).find('[class*="iconContainer_"]')[0].className.indexOf('expiring_') >= 0){
$($(event.target)[0].offsetParent).find('[class*="phase"]').find('[class*="title"]').attr('style', 'color: #222221')
}
}else{
if($($(event.target)[0].offsetParent).find('[class*="iconContainer_"]')[0].className.indexOf('expiring_') >= 0){
$($(event.target)[0].offsetParent).find('[class*="phase"]').find('[class*="title"]').attr('style', 'color: #f7c327').detach().insertBefore($($(event.target)[0].offsetParent).find('[class*="panelBody"]'));
}
else{
$($(event.target)[0].offsetParent).find('[class*="phase"]').find('[class*="title"]').detach().insertBefore($($(event.target)[0].offsetParent).find('[class*="panelBody"]'));
}
$($(event.target)[0].offsetParent).find('[class*="reward_"]').detach().insertBefore($($(event.target)[0].offsetParent).find('[class*="panelBody"]'));
$($(event.target)[0].offsetParent).find($('[class*="rewardContainer_"]')).hide()
}
}
});