// ==UserScript== // @name Some Arrangements // @namespace http://tampermonkey.net/ // @version 0.231 // @description try to take over the world! // @author AlegreVida // @match https://s46-tr.ikariam.gameforge.com/?view=city* // @match https://s46-tr.ikariam.gameforge.com/?view=island* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; /* var buildingUpgrade = true; var premiumOffers = true; var dailyTasks = true; var donation = true; var workshop = true; var unitsInCity = true; var culturalExchange = true; $('#GF_toolbar>ul').append("
  • Script Ayarları
  • "); function displayScriptSettings(flag){ if(flag){ $('#GF_toolbar>ul').append( "
    " + "
    " + "
    Ayarlar
    " + "
    X
    " + "
    " + "
    " + "
    " + "
    " + "" + "" + "
    " + "" + "" + "
    " + "" + "" + "
    " + "" + "" + "
    " + "" + "" + "
    " + "" + "" + "
    " + "" + "" + "
    " + "
    " + "" + "
    " + "
    "+ "
    "); $('#hideScriptSettings').click(function(){ displayScriptSettings(false); }); }else{ $('#scriptSettingsDiv').remove(); } } $('#scriptSettings').click(function(){ displayScriptSettings( $('#scriptSettingsDiv').length == 0); }); $(document).ready(function() { $(document).on('submit', '#scriptSettingsForm', function() { alert("Form Submitted"); return false; }); }); */ var res = ['wood', 'marble', 'wine', 'glass', 'sulfur']; function ikaNumberStyle(num, withPlus){ var isMinus = (num < 0); num = Math.abs(num) + ""; if(num.length > 6){ num = num.substring(0, num.length-6) + "," + num.substring(num.length-6, num.length-3) + "," + num.substring(num.length-3, num.length); }else if(num.length > 3){ num = num.substring(0, num.length-3) + "," + num.substring(num.length-3, num.length); } return (isMinus ? "-" + num : ((withPlus) ? "+" : "") + num); }; function fnc_BuildingUpgradeListener(){ function fnc_BuildingUpgrade(){ function spanHTML(val, type){ var res = ['wood', 'marble', 'wine', 'glass', 'sulfur']; return ' (' + ikaNumberStyle(val, 1) + ')'; } function changeSpanHTML(el, player, needed, type){ if(!isNaN(needed)){ if($(el).length){ $(el).text(' (' + ikaNumberStyle(player - needed, 1) + ')'); $(el).css("color", (player - needed < 0) ? "red" : "green"); }else{ $(root).find('.' + res[type]).append(spanHTML(player - needed, type)); } } } var root = $('#buildingUpgrade .resources'); var needed_wood = parseInt($(root).find('.wood').clone().children().remove().end().text().replace(",", "")); var needed_marble = parseInt($(root).find('.marble').clone().children().remove().end().text().replace(",", "")); var needed_wine = parseInt($(root).find('.wine').clone().children().remove().end().text().replace(",", "")); var needed_glass = parseInt($(root).find('.glass').clone().children().remove().end().text().replace(",", "")); var needed_sulfur = parseInt($(root).find('.sulfur').clone().children().remove().end().text().replace(",", "")); var player_wood = parseInt($('#js_GlobalMenu_wood').text().replace(",", "")); var player_marble = parseInt($('#js_GlobalMenu_marble').text().replace(",", "")); var player_wine = parseInt($('#js_GlobalMenu_wine').text().replace(",", "")); var player_glass = parseInt($('#js_GlobalMenu_crystal').text().replace(",", "")); var player_sulfur = parseInt($('#js_GlobalMenu_sulfur').text().replace(",", "")); changeSpanHTML($('#afterUpgrade_wood'), player_wood, needed_wood, 0); changeSpanHTML($('#afterUpgrade_marble'), player_marble, needed_marble, 1); changeSpanHTML($('#afterUpgrade_wine'), player_wine, needed_wine, 2); changeSpanHTML($('#afterUpgrade_glass'), player_glass, needed_glass, 3); changeSpanHTML($('#afterUpgrade_sulfur'), player_sulfur, needed_sulfur, 4); $(root).find('li').css("width", "150px"); } var params_BuildingUpgrade = { id: 'buildingUpgrade', parent: document.querySelector('body'), recursive: false, done: function() { fnc_BuildingUpgrade(); } }; new MutationObserver(function(mutations) { params_BuildingUpgrade.done(); }).observe(params_BuildingUpgrade.parent || document, { childList: true }); }; fnc_BuildingUpgradeListener(); function fnc_TownHallListener(){ function fnc_TownHall(){ $('#townHall .premiumOffer').remove(); $('#townHall .mainContentScroll').css("height", ""); var occupiedSpace = parseInt($('#js_TownHallOccupiedSpace').text()); var maxInhabitants = parseInt($('#js_TownHallMaxInhabitants').text()); var space = maxInhabitants - occupiedSpace; var happiness = parseInt($('#js_TownHallHappinessLargeValue').text()); var text = "Boş Konut: " + space; if(space > 0){ var happinessAfterFull = happiness - space; var avgSpeed = (happiness + happinessAfterFull)/2/50; var t = space / avgSpeed; var timeText = Math.floor(t*60)%60 + ' dk'; if(Math.floor(t) > 0){ timeText = Math.floor(t) + ' saat ' + timeText; } text += ' (' + timeText + ')'; } $('#townHall .stats .space').html(text); } var params_TownHall = { id: 'townHall', parent: document.querySelector('body'), recursive: false, done: function() { fnc_TownHall(); } }; new MutationObserver(function(mutations) { params_TownHall.done(); }).observe(params_TownHall.parent || document, { childList: true }); }; fnc_TownHallListener(); function fnc_BarracksListener(){ function fnc_Barracks(){ $('#premium_btn').remove(); } var params_Barracks = { id: 'townHall', parent: document.querySelector('body'), recursive: false, done: function() { fnc_Barracks(); } }; new MutationObserver(function(mutations) { params_Barracks.done(); }).observe(params_Barracks.parent || document, { childList: true }); }; fnc_BarracksListener(); function fnc_DailyTasksListener(){ function fnc_DailyTasks(){ $('#dailyTasks table.table01 tr.textLineThrough').remove(); $('#dailyTasks .mainContentScroll').css("height", ""); } var params_DailyTasks = { id: 'dailyTasks', parent: document.querySelector('body'), recursive: false, done: function() { fnc_DailyTasks(); } }; new MutationObserver(function(mutations) { params_DailyTasks.done(); }).observe(params_DailyTasks.parent || document, { childList: true }); }; fnc_DailyTasksListener(); function fnc_DonationListener(){ function fnc_Donation(){ if($('.resUpgrade').length){ if($('li.accordionItem').length > 1){ $("li.accordionItem:last").empty(); } var root = $('li.accordionItem:first .resUpgrade'); var totalNeeded = parseInt($("li.accordionItem li.wood:first").text().replace(',', '')); var current = parseInt($("li.accordionItem li.wood:last").text().replace(',', '')); var needed = totalNeeded - current; $("#sidebarWidget .resUpgrade:first ul").remove(); $("#sidebarWidget .resUpgrade:first h4").remove(); if( $('#upgradeCountDown').length < 1 ){ $(root).find(".building_level").after('

    Gereken:

    '); } } }; var params_Donation = { parent: document.querySelector('body'), recursive: false, done: function() { fnc_Donation(); } }; new MutationObserver(function(mutations) { params_Donation.done(); }).observe(params_Donation.parent || document, { childList: true }); }; fnc_DonationListener(); function fnc_x(){ function fnc_xx(){ if( $('#js_treatiesConfirm option[value=77]').length ){ $('#js_treatiesConfirm option[value=77]').attr('selected', 'selected'); } }; var params_Xxx = { id: 'sendIKMessage', parent: document.querySelector('body'), recursive: false, done: function() { fnc_xx(); } }; new MutationObserver(function(mutations) { params_Xxx.done(); }).observe(params_Xxx.parent || document, { childList: true }); }; fnc_x(); function fnc_WorkshopListener(){ function fnc_Workshop(){ var root_Units = $('#workshop #tabUnits .content'); var root_Ships = $('#workshop #tabShips .content'); for(var i = 1; i <= $(root_Units).find('.units').length; i++){ if( $(root_Units).find('.units:nth-child(' + i + ') a').length == 0 ){ $(root_Units).find('.units:nth-child(' + i + ')').empty(); } } for(var i2 = 1; i2 <= $(root_Ships).find('.units').length; i2++){ if( $(root_Ships).find('.units:nth-child(' + i2 + ') a').length == 0 ){ $(root_Ships).find('.units:nth-child(' + i2 + ')').empty(); } } if($(root_Units).find('.units').length == 0){ $(root_Units).empty(); $(root_Units).append('

    HELAL LAN SANA !!!

    '); } if($(root_Ships).find('.units').length == 0){ $(root_Ships).empty(); $(root_Ships).append('

    HELAL LAN SANA !!!

    '); } }; var params_Workshop = { id: 'workshop', parent: document.querySelector('body'), recursive: false, done: function() { fnc_Workshop(); } }; new MutationObserver(function(mutations) { params_Workshop.done(); }).observe(params_Workshop.parent || document, { childList: true }); }; fnc_WorkshopListener(); function fnc_UnitsInCityListener(){ function fnc_UnitsInCity(){ var units_FirstRow = $('#cityMilitary #tabUnits .content:first table.table01:first'); var units_SecondRow = $('#cityMilitary #tabUnits .content:first table.table01:last'); var ships_FirstRow = $('#cityMilitary #tabShips .content table.table01:first'); var ships_SecondRow = $('#cityMilitary #tabShips .content table.table01:last'); var length_Units1 = $(units_FirstRow).find('tr.count td').length; var length_Units2 = $(units_SecondRow).find('tr.count td').length; var length_Ships1 = $(ships_FirstRow).find('tr.count td').length; var length_Ships2 = $(ships_SecondRow).find('tr.count td').length; for(var i1 = length_Units1; i1 > 1; i1--){ var root_Units1 = $(units_FirstRow).find('tr.count td:nth-child(' + i1 + ')'); var number_Units1 = $(root_Units1).text().slice(0, root_Units1.text().indexOf(' ')); if(number_Units1 === "-" || number_Units1 == "0"){ root_Units1.remove(); $(units_FirstRow).find('tr.title_img_row th:nth-child(' + i1 + ')').remove(); } } for(var i2 = length_Units2; i2 > 1; i2--){ var root_Units2 = $(units_SecondRow).find('tr.count td:nth-child(' + i2 + ')'); var number_Units2 = $(root_Units2).text().slice(0, root_Units2.text().indexOf(' ')); if(number_Units2 === "-" || number_Units2 == "0"){ root_Units2.remove(); $(units_SecondRow).find('tr.title_img_row th:nth-child(' + i2 + ')').remove(); } } for(var k1 = length_Ships1; k1 > 1; k1--){ var root_Ships1 = $(ships_FirstRow).find('tr.count td:nth-child(' + k1 + ')'); var number_Ships1 = $(root_Ships1).text().trim(); if(number_Ships1 === "-" || number_Ships1 == "0"){ root_Ships1.remove(); $(ships_FirstRow).find('tr.title_img_row th:nth-child(' + k1 + ')').remove(); } } for(var k2 = length_Ships2; k2 > 1; k2--){ var root_Ships2 = $(ships_SecondRow).find('tr.count td:nth-child(' + k2 + ')'); var number_Ships2 = $(root_Ships2).text().trim(); if(number_Ships2 === "-" || number_Ships2 == "0"){ root_Ships2.remove(); $(ships_SecondRow).find('tr.title_img_row th:nth-child(' + k2 + ')').remove(); } } if($(units_FirstRow).find('tr.count td').length == 1){ $(units_FirstRow).remove(); } if($(units_SecondRow).find('tr.count td').length == 1){ $(units_SecondRow).remove(); } if($(ships_FirstRow).find('tr.count td').length == 1){ $(ships_FirstRow).remove(); } if($(ships_SecondRow).find('tr.count td').length == 1){ $(ships_SecondRow).remove(); } }; var params_UnitsInCity = { id: 'cityMilitary', parent: document.querySelector('body'), recursive: false, done: function() { fnc_UnitsInCity(); } }; new MutationObserver(function(mutations) { params_UnitsInCity.done(); }).observe(params_UnitsInCity.parent || document, { childList: true }); }; fnc_UnitsInCityListener(); function fnc_AdvisorListener(){ function fnc_TradeAdvisor(){ if($('#js_premiumAccountOffer').length > 0){ $('#tradeAdvisor .contentBox01h:last').remove(); $('#tradeAdvisor .mainContentScroll:first').css("height", ""); } }; function fnc_MilitaryAdvisor(){ if($('#js_premiumAccountOffer').length > 0){ $('#militaryAdvisor .contentBox01h:last').remove(); } }; function fnc_ResearchAdvisor(){ if($('#js_premiumAccountOffer').length > 0){ $('#researchAdvisor .contentBox01h:last').remove(); } }; function fnc_DiplomacyAdvisor(){ if($('#js_premiumAccountOffer').length > 0){ $('#diplomacyAdvisor .contentBox01h:last').remove(); $('#diplomacyAdvisor .mainContentScroll:first').css("height", ""); } }; var params_TradeAdvisor = { id: 'tradeAdvisor', parent: document.querySelector('body'), recursive: false, done: function() { fnc_TradeAdvisor(); } }; var params_MilitaryAdvisor = { id: 'militaryAdvisor', parent: document.querySelector('body'), recursive: false, done: function() { fnc_MilitaryAdvisor(); } }; var params_ResearchAdvisor = { id: 'researchAdvisor', parent: document.querySelector('body'), recursive: false, done: function() { fnc_ResearchAdvisor(); } }; var params_DiplomacyAdvisor = { id: 'diplomacyAdvisor', parent: document.querySelector('body'), recursive: false, done: function() { fnc_DiplomacyAdvisor(); } }; new MutationObserver(function(mutations) { params_TradeAdvisor.done(); }).observe(params_TradeAdvisor.parent || document, { childList: true }); new MutationObserver(function(mutations) { params_MilitaryAdvisor.done(); }).observe(params_MilitaryAdvisor.parent || document, { childList: true }); new MutationObserver(function(mutations) { params_ResearchAdvisor.done(); }).observe(params_ResearchAdvisor.parent || document, { childList: true }); new MutationObserver(function(mutations) { params_DiplomacyAdvisor.done(); }).observe(params_DiplomacyAdvisor.parent || document, { childList: true }); }; fnc_AdvisorListener(); // Araştırmadaki Listeyi Düzelt var flag_Workshop = true; var flag_ResearchAdvisor = true; var listener_ResearchAdvisor = $('body').on('DOMSubtreeModified', '#researchAdvisor', fnc_ResearchAdvisor); function fnc_ResearchAdvisor(){ if($('#researchAdvisor').length > 0 && flag_Workshop){ flag_Workshop = false; $('#researchAdvisor #js_researchAdvisorCurrResearchesArr a').css('float', 'right'); $('#researchAdvisor #js_researchAdvisorCurrResearchesArr a').css('margin', '0'); flag_Workshop = true; } } /* Example Listener function fnc_Listener(){ function fnc(){ }; var params = { id: 'element_id', parent: document.querySelector('body'), recursive: false, done: function() { fnc(); } }; new MutationObserver(function(mutations) { params.done(); }).observe(params.parent || document, { childList: true }); }; fnc_Listener(); ???????????????????????????? const targetNode = document.getElementById('dailyTasks')[0]; const config = { attributes: true, childList: true, subtree: true }; const observer = new MutationObserver(callback); observer.observe(targetNode, config); observer.disconnect(); */ })();