NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name ShowAllRe // @version 6.1.6.11 // @description ShowAllRe // @author iguypouf // @updateURL https://openuserjs.org/meta/iguypouf/ShowAllRe.meta.js // @include http*.ogame.gameforge.com/game/index.php?page=messages* // @include http*.ogame.gameforge.com/game/index.php?page=preferences* // @require https://code.jquery.com/jquery-2.1.4.min.js // @grant GM_getValue // @grant GM_setValue // @grant GM_xmlhttpRequest // ==/UserScript== var showReControl, showReCmd, maxWait = 25; // Helper function for select the report function SelectRe(element) { var text = document.getElementById(element); if (document.body.createTextRange) { range = document.body.createTextRange(); range.moveToElementText(text); range.select(); } else if (window.getSelection) { selection = window.getSelection(); range = document.createRange(); range.selectNodeContents(text); selection.removeAllRanges(); selection.addRange(range); } } // Global call to start the survey, bound on tabs and load function launchMonitor() { showReControl = 0; showReCmd = setInterval(showRe,200); } // Global call to start the survey, bound on tabs and load function displayOptions() { PlaceHolder = $("<div/>", {'class' : 'category fieldwrapper alt bar' }); $(PlaceHolder).html('<label class="styled textBeefy">Options of the script ShowAllRe</label>'); $(PlaceHolder).appendTo($("#four")); PlaceHolder = $("<div/>", {'class' : 'group bborder', 'style' : 'display: block' }); sChecked = (GM_getValue('ShowAllRe_'+getPlayerId()+'_keepheader','').length>0) ? ' checked' : ''; sShowOptions = '<div class="fieldwrapper"><label class="styled textBeefy">Keep the Vanilla Report Header :</label><div class="thefield"><input type="checkbox"' + sChecked + ' id="ShowAllRE_KeepHeader"></div></div>'; $(PlaceHolder).html(sShowOptions); $(PlaceHolder).appendTo($("#four")); $('#ShowAllRE_KeepHeader').click( function() { HandleOption('ShowAllRe_'+getPlayerId()+'_keepheader'); } ); } // Isolate the id for storing report function uniqueId(url) { var id_mask = /[?&]messageId=([^&]+)/i; var match = id_mask.exec(url); if (match !== null) { return getPlayerId()+''+match[1]; } else { return ''; } } function getPlayerId() { var playerid = $("meta[name=ogame-player-id]").attr("content"); return playerid; } // Manage Stored Options function HandleOption(HO_id) { if(GM_getValue(HO_id,'').length>0) GM_setValue(HO_id,''); else GM_setValue(HO_id,'Option_checked'); } // Fire the display if monitor loop comes after load or reload function showRe() { var bKeepHeader = (GM_getValue('ShowAllRe_'+getPlayerId()+'_keepheader','').length>0); if(showReControl<=maxWait) { if($('.msg').length>0 && $('.msg').length>$('.showRePlaceHolder').length) { $('ul.subtabs a, ul.tabs_btn a, .paginator').bind('click', function() { launchMonitor(); }); showReControl = maxWait; $.each($('.msg'), function(index ,value ) { if($(value).find('.resspan').length>0) { // Identify the Spy Report RELink = $(value).find('.msg_action_link').attr("href"); REId = uniqueId(RELink); REStored = GM_getValue('ShowAllRe_'+REId,''); // Get Res Name - Internationalization met_name = $(value).find('.msg_content .resspan:eq(0)').html(); met_name = met_name.substr(0,met_name.indexOf(':')); cri_name = $(value).find('.msg_content .resspan:eq(1)').html(); cri_name = cri_name.substr(0,cri_name.indexOf(':')); deut_name = $(value).find('.msg_content .resspan:eq(2)').html(); deut_name = deut_name.substr(0,deut_name.indexOf(':')); // Improve the basic view if(!bKeepHeader) { if($(value).find('.msg_content font').html()) { $(value).find('.msg_title').html($(value).find('.msg_title').html()+' <font color="#ff0000">'+$(value).find('.msg_content font').html()+'</font>'); } $(value).find('.msg_content br').remove(); // Condensed $(value).find('.msg_content .ctn4:eq(1)').remove(); // Activity $(value).find('.msg_content .ctn4:eq(1)').remove(); // Detailed Ress $(value).find('.msg_content .compacting:eq(0) a').remove(); // Second Coords $(value).find('.msg_content .compacting:eq(1)').html('<br>'+$(value).find('.msg_content .compacting:eq(1) span').attr('title').replace(/<br\/>/g,' | ')); // Transpo $(value).find('.msg_sender').append(' ('+$(value).find('.msg_content .compacting:eq(2) span.fright').html()+')'); $(value).find('.msg_content .compacting:eq(2)').remove(); // Probability Spy Detection $(value).find('.msg_content .compacting:eq(1)').append('<br>'+$(value).find('.msg_content .compacting:eq(2) span:eq(0)').html()+' [<span class="showReFleetSum">'+$(value).find('.msg_content .compacting:eq(2) span:eq(0)').attr('title')+'</span>]'); $(value).find('.msg_content .compacting:eq(1)').append('<br>'+$(value).find('.msg_content .compacting:eq(2) span:eq(1)').html()+' [<span class="showReDefSum">'+$(value).find('.msg_content .compacting:eq(2) span:eq(1)').attr('title')+'</span>]'); $(value).find('.msg_content .compacting:eq(2)').remove(); // Def & Fleet } $(value).find('.msg_actions').prepend('<a id="showRe_copy_'+index+'" class="icon_nf_link fleft" href="javascript:void(0);"><span class="icon_nf"></span></a>'); // Select button for Speedsim $('#showRe_copy_'+index).bind('click',function() { SelectRe('showRe_'+index); }); // Load the detail view PlaceHolder = $("<div/>", {'id' : 'showRe_'+index, 'class' : 'showRePlaceHolder' }).appendTo($(value)); if(REStored==='') { $(PlaceHolder).load(RELink + ' .detail_msg', null, function() { $(value).find('.detail_msg').css('width','100%'); $(value).find('.detail_msg .resource_list_el').css({ 'width' : '27%', 'margin' : '0' }); $(value).find('.detail_msg .resource_list_el:eq(3)').css({ 'width' : '19%' }); $(value).find('.detail_msg .detail_list_el').css({ 'width' : '50%', 'margin' : '0', 'height' : '16px', 'line-height' : '16px' }); $(value).find('.detail_msg .msg_actions').remove(); $(value).find('.detail_msg .msg_title figure').remove(); $(value).find('.detail_msg .msg_title').prepend('sur ').append(' ('+$(value).find('.msg_content .compacting:eq(0)').html()+')'); $(value).find('.detail_msg_ctn .detail_txt:eq(1)').remove(); $(value).find('.detail_msg_ctn span span:eq(0)').remove(); $(value).find('.detail_msg_ctn span span:eq(0)').remove(); $(value).find('.detail_msg .ctn_with_new_msg').remove(); $(value).find('.detail_msg_ctn br.clearfloat').remove(); $(value).find('.detail_msg_ctn div.section_title:last').remove(); $(value).find('.resource_list_el:eq(0)').html(met_name + ' : ' + $(value).find('.resource_list_el:eq(0)').attr('title')); $(value).find('.resource_list_el:eq(1)').html(cri_name + ' : ' + $(value).find('.resource_list_el:eq(1)').attr('title')); $(value).find('.resource_list_el:eq(2)').html(deut_name + ' : ' + $(value).find('.resource_list_el:eq(2)').attr('title')); $(value).find('.resource_list_el:eq(3)').html('Energy : ' + $(value).find('.resource_list_el:eq(3)').attr('title')); $(value).find('.detail_list_el').html(function(index,html) { return html.replace('Sonde d`espionnage','Sonde espionnage'); }); ThisREId = uniqueId($(value).find('.msg_action_link').attr("href")); ReDet = $(value).find('.detail_msg'); if(ReDet.length>0) GM_setValue('ShowAllRe_'+ThisREId, ReDet.html()); }); } else $(PlaceHolder.html('<div class="detail_msg" style="width:100%">'+REStored+'</div>')); } }); } } showReControl++; if(showReControl>maxWait) clearInterval(showReCmd); } if(/page=message/.test(location.href)) { launchMonitor(); } if(/page=preference/.test(location.href)) { displayOptions(); }