Greasy Fork is available in English.
try to take over the world!
当前为
// ==UserScript==
// @name Arrangements
// @namespace http://tampermonkey.net/
// @version 1.0.2
// @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
// ==/UserScript==
(function() {
'use strict';
function setCookie(key, value, expiry) {
var expires = new Date();
expires.setTime(expires.getTime() + (expiry * 24 * 60 * 60 * 1000));
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
}
function getCookie(key) {
var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;
}
function eraseCookie(key) {
var keyValue = getCookie(key);
setCookie(key, keyValue, '-1');
}
var myIkaCookies;
if(getCookie("myIkaCookies") != null){
myIkaCookies = JSON.parse(getCookie("myIkaCookies"));
console.log("MY IKA COOKIES FOUND!");
}else{
myIkaCookies = {
buildingUpgrade: true,
townHall: true,
premiumOffers: true,
dailyTasks: true,
donation: true,
workshop: true,
unitsInCity: true,
culturalExchange: true,
warehouse: false,
barracks: false,
shipyard: false
};
console.log("MY IKA COOKIES NOT FOUND!");
setCookie("myIkaCookies", JSON.stringify(myIkaCookies), 3);
}
$('#GF_toolbar>ul').append("<li id='scriptSettings' style='font-weight:bold; font-size:11px'>Script Ayarları</li>");
$('#scriptSettings').mouseenter(function(){
$(this).css('cursor','pointer');
$('#scriptSettings').css("color", "green");
});
$('#scriptSettings').mouseleave(function(){
$('#scriptSettings').css("color", "black");
});
function displayScriptSettings(flag){
myIkaCookies = JSON.parse(getCookie("myIkaCookies"));
if(flag){
$('#GF_toolbar>ul').append(
"<div id='scriptSettingsDiv' style='height: auto; width: auto; z-index: 100; background-color: black; float:right;background-color:#fff8d7;padding:4px;border-radius:8px'>" +
"<div>" +
"<div style='text-align:center;width:90%;float:left'>Ayarlar</div>" +
"<div id='hideScriptSettings' style='font-weight:bold;width:5%;float:right;margin-right:4px;cursor:pointer'>X</div>" +
"</div>" +
"<hr style='width: 95%;margin: 4px auto 4px auto;padding: 0px;'>" +
"<div style='width:100%;padding:4px'>" +
"<form id='scriptSettingsForm'>" +
"<input id='script_BuildingUpgrade' type='checkbox' style='margin-left:4px;margin-right:4px' " + (myIkaCookies.buildingUpgrade ? "checked='checked'" : '') + " />" +
"<label class='script-labels' for='script_BuildingUpgrade' style='margin-right:4px' >Bina Yükseltmelerinde Kaynak Durumu Göster</label>" +
"<br/>" +
"<input id='script_TownHall' type='checkbox' style='margin-left:4px;margin-right:4px' " + (myIkaCookies.townHall ? "checked='checked'" : '') + " />" +
"<label class='script-labels' for='script_TownHall' style='margin-right:4px' >Belediye Binasında Nüfusun Dolması için Kalan Süre</label>" +
"<br/>" +
"<input id='script_PremiumOffers' type='checkbox' style='margin-left:4px;margin-right:4px' " + (myIkaCookies.premiumOffers ? "checked='checked'" : '') + " />" +
"<label class='script-labels' for='script_PremiumOffers' style='margin-right:4px' >Premium ve Vatandaş Tekliflerini Gizle</label>" +
/*"<ul>" +
"<li style='display:block'>Belediye Binası</li>" +
"<li style='display:block'>Kışla</li>" +
"<li style='display:block'>Şehir Danışmanı</li>" +
"<li style='display:block'>Ordu Danışmanı</li>" +
"<li style='display:block'>Araştırma Danışmanı</li>" +
"<li style='display:block'>Diplomasi Danışmanı</li>" +
"</ul>"+*/
"<br/>" +
"<input id='script_DailyTasks' type='checkbox' style='margin-left:4px;margin-right:4px' " + (myIkaCookies.dailyTasks ? "checked='checked'" : '') + " />" +
"<label class='script-labels' for='script_DailyTasks' style='margin-right:4px' >Tamamlanan Günlük Görevleri Gizle</label>" +
"<br/>" +
"<input id='script_Donation' type='checkbox' style='margin-left:4px;margin-right:4px' " + (myIkaCookies.donation ? "checked='checked'" : '') + " />" +
"<label class='script-labels' for='script_Donation' style='margin-right:4px' >Üretim Yeri İçin Gereken Bağışı Göster</label>" +
"<br/>" +
"<input id='script_Workshop' type='checkbox' style='margin-left:4px;margin-right:4px' " + (myIkaCookies.workshop ? "checked='checked'" : '') + " />" +
"<label class='script-labels' for='script_Workshop' style='margin-right:4px' >Mucit Atölyesinde Tamamlanan Yükseltmeleri Gizle</label>" +
"<br/>" +
"<input id='script_UnitsInCity' type='checkbox' style='margin-left:4px;margin-right:4px' " + (myIkaCookies.unitsInCity ? "checked='checked'" : '') + " />" +
"<label class='script-labels' for='script_UnitsInCity' style='margin-right:4px' >Şehirdeki Birliklerde Sadece Var Olanları Göster</label>" +
"<br/>" +
"<input id='script_CulturalExchange' type='checkbox' style='margin-left:4px;margin-right:4px' " + (myIkaCookies.culturalExchange ? "checked='checked'" : '') + " />" +
"<label class='script-labels' for='script_CulturalExchange' style='margin-right:4px' >Mesajlaşmada Kültürel Anlaşmaya Öncelik</label>" +
"<br/>" +
"<input id='script_Warehouse' type='checkbox' style='margin-left:4px;margin-right:4px' " + (myIkaCookies.warehouse ? "checked='checked'" : '') + " />" +
"<label class='script-labels' for='script_Warehouse' style='margin-right:4px' >Depoda Güvenli Miktara Ne Kadar Kaldığını Göster</label>" +
"<br/>" +
"<input id='script_Barracks' type='checkbox' style='margin-left:4px;margin-right:4px' " + (myIkaCookies.barracks ? "checked='checked'" : '') + " />" +
"<label class='script-labels' for='script_Barracks' style='margin-right:4px' >Kışladaki Görünümünü Güncelle</label>" +
"<br/>" +
"<input id='script_Shipyard' type='checkbox' style='margin-left:4px;margin-right:4px' " + (myIkaCookies.shipyard ? "checked='checked'" : '') + " />" +
"<label class='script-labels' for='script_Shipyard' style='margin-right:4px' >Donanma Tersanesindeki Görünümünü Güncelle</label>" +
"<br/>" +
"<hr style='width: 95%;margin: 4px auto 4px auto;padding: 0px;'>" +
"<input type='submit' value='Kaydet' class='button' style='margin:4px 8px 4px 0px;float:right;padding:2px;border-radius:4px'>" +
"</form>" +
"</div>"+
"</div>");
$('#hideScriptSettings').mouseenter(function(){
$(this).css('cursor','pointer');
$('#hideScriptSettings').css("color", "red");
});
$('#hideScriptSettings').mouseleave(function(){
$('#hideScriptSettings').css("color", "black");
});
/*for(var i = 1; i <= $('#scriptSettingsForm .script-labels').length; i++){
var label = $('#scriptSettingsForm .script-labels:nth-of-type(' + i + ')');
$(label).mouseenter(function(){
console.log("MOUSE ENTER => " + $(label).text());
$(label).css("font-weight", "bold");
});
$(label).mouseleave(function(){
console.log("MOUSE LEAVE => " + $(label).text());
$(label).css("font-weight", "");
});
}*/
$('#hideScriptSettings').click(function(){
displayScriptSettings(false);
});
}else{
$('#scriptSettingsDiv').remove();
}
}
$('#scriptSettings').click(function(){
displayScriptSettings( $('#scriptSettingsDiv').length == 0);
});
function listenerControl(){
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_BuildingUpgrade(){
function spanHTML(val, type){
var res = ['wood', 'marble', 'wine', 'glass', 'sulfur'];
return '<span id="afterUpgrade_' + res[type] + '" style="color:' + ((val >= 0) ? 'green' : 'red') + '"> (' + ikaNumberStyle(val, 1) + ')</span>';
}
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");
}
function fnc_TownHall(){
$('#townHall .mainContentScroll').css("height", "");
if($('#timeLeftToFullyPopulate').length){
return;
}
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 += '<span id="timeLeftToFullyPopulate"> (' + timeText + ')</span>';
}
$('#townHall .stats .space').html(text);
}
function fnc_TownHall_PremiumOffer(){
$('#townHall .premiumOffer').remove();
}
function fnc_Barracks_PremiumOffer(){
$('#premium_btn').remove();
}
function fnc_TradeAdvisor_PremiumOffer(){
if($('#js_premiumAccountOffer').length > 0){
$('#tradeAdvisor .contentBox01h:last').remove();
$('#tradeAdvisor .mainContentScroll:first').css("height", "");
}
};
function fnc_MilitaryAdvisor_PremiumOffer(){
if($('#js_premiumAccountOffer').length > 0){
$('#militaryAdvisor .contentBox01h:last').remove();
}
}
function fnc_ResearchAdvisor_PremiumOffer(){
if($('#js_premiumAccountOffer').length > 0){
$('#researchAdvisor .contentBox01h:last').remove();
}
}
function fnc_DiplomacyAdvisor_PremiumOffer(){
if($('#js_premiumAccountOffer').length > 0){
$('#diplomacyAdvisor .contentBox01h:last').remove();
$('#diplomacyAdvisor .mainContentScroll:first').css("height", "");
}
}
function fnc_DailyTasks(){
if($('#script_ShowHideCompletedDailyTasks').length == 0){
$('#dailyTasks>.mainContentScroll>.mainContent>.buildingDescription>div:nth-of-type(1)').append('<button id="script_ShowHideCompletedDailyTasks" show="0" style="float: right; margin-right: 15px;" class="button">Tamamlananları Göster</button>');
}
hideCompletedDaily();
clickListener_ShowHideCompletedDailyTasks();
}
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('<h4 class="bold center">Gereken:</h4><ul class="resources"><li class="wood">' + ikaNumberStyle(needed, 0) + '</li></ul>');
}
}
}
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('<h2 style="font-size: 40px;text-align: center;margin-top: 50px;margin-bottom: 50px;"> HELAL LAN SANA !!! </h2>');
}
if($(root_Ships).find('.units').length == 0){
$(root_Ships).empty();
$(root_Ships).append('<h2 style="font-size: 40px;text-align: center;margin-top: 50px;margin-bottom: 50px;"> HELAL LAN SANA !!! </h2>');
}
}
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();
}
}
function fnc_CulturalExchange(){
if( $('#js_treatiesConfirm option[value=77]').length ){
$('#js_treatiesConfirm option[value=77]').attr('selected', 'selected');
}
}
function fnc_Warehouse(){
if($('#warehouse').length > 0){
$('#js_total_safe_capacity').css('color', 'green');
var capacity = parseInt($('#js_total_safe_capacity').text().replace(',', ''));
var arr = ["wood", "wine", "marble", "glass", "sulfur"];
for (var keyword of arr){
var total = parseInt($('#js_total_' + keyword).text().replace(',', ''));
if(capacity > total){
if($('#js_stillSafe_' + keyword).length > 0){
$('#js_stillSafe_' + keyword).text('(' + ikaNumberStyle(total-capacity, true) + ')');
}else{
$('#js_plunderable_' + keyword).after('<span style="color:green;margin-left:4px" id="js_stillSafe_' + keyword + '">(' + ikaNumberStyle(total-capacity, true) + ')</span>')
}
}
}
}
}
function fnc_Barracks(){
for (var i = 1; i <= $('#barracks #units li').length; i++){
var element = $('#barracks #units li:nth-of-type('+i+')');
$(element).find('div:first p').remove();
$(element).css("min-height", "100px");
$(element).find('div:first a img').css("height", "75px");
$(element).find('div:first a img').css("left", "20px");
$(element).find('div:first div').css("bottom", "16px");
$(element).find('div.forminput:first').css("bottom", "50px");
$('#buildUnits div:first p').remove();
$('#barracks .mainContentScroll:first').css("height", "");
}
}
function fnc_Shipyard(){
for (var i = 1; i <= $('#shipyard #units li').length; i++){
var element = $('#shipyard #units li:nth-of-type('+i+')');
$(element).find('div:first p').remove();
$(element).css("min-height", "100px");
$(element).find('div:first a img').css("height", "75px");
$(element).find('div:first a img').css("left", "20px");
$(element).find('div:first div').css("bottom", "16px");
$(element).find('div.forminput:first').css("bottom", "50px");
$('#buildUnits div:first p').remove();
$('#shipyard .mainContentScroll:first').css("height", "");
}
}
createListener(myIkaCookies.buildingUpgrade, "buildingUpgrade", fnc_BuildingUpgrade);
createListener(myIkaCookies.townHall, "townHall", fnc_TownHall);
createListener(myIkaCookies.premiumOffers, "townHall", fnc_TownHall_PremiumOffer);
createListener(myIkaCookies.premiumOffers, "barracks", fnc_Barracks_PremiumOffer);
createListener(myIkaCookies.premiumOffers, "tradeAdvisor", fnc_TradeAdvisor_PremiumOffer);
createListener(myIkaCookies.premiumOffers, "militaryAdvisor", fnc_MilitaryAdvisor_PremiumOffer);
createListener(myIkaCookies.premiumOffers, "researchAdvisor", fnc_ResearchAdvisor_PremiumOffer);
createListener(myIkaCookies.premiumOffers, "diplomacyAdvisor", fnc_DiplomacyAdvisor_PremiumOffer);
createListener(myIkaCookies.dailyTasks, "dailyTasks", fnc_DailyTasks);
createListener(myIkaCookies.donation, "", fnc_Donation);
createListener(myIkaCookies.workshop, "workshop", fnc_Workshop);
createListener(myIkaCookies.unitsInCity, "cityMilitary", fnc_UnitsInCity);
createListener(myIkaCookies.culturalExchange, "sendIKMessage", fnc_CulturalExchange);
createListener(myIkaCookies.warehouse, "warehouse", fnc_Warehouse);
createListener(myIkaCookies.barracks, "barracks", fnc_Barracks);
createListener(myIkaCookies.shipyard, "shipyard", fnc_Shipyard);
}
function clickListener_ShowHideCompletedDailyTasks(){
$('#script_ShowHideCompletedDailyTasks').click(function(){
if($('#script_ShowHideCompletedDailyTasks').attr("show") == "0"){
showCompletedDaily();
}else{
hideCompletedDaily();
}
});
}
function hideCompletedDaily(){
$('#dailyTasks table.table01 tr.textLineThrough').hide();
$('#dailyTasks .mainContentScroll').css("height", "");
$('#script_ShowHideCompletedDailyTasks').attr("show", "0");
$('#script_ShowHideCompletedDailyTasks').text("Tamamlananları Göster");
}
function showCompletedDaily(){
$('#dailyTasks table.table01 tr.textLineThrough').show();
$('#dailyTasks .mainContentScroll').css("height", "");
$('#script_ShowHideCompletedDailyTasks').attr("show", "1");
$('#script_ShowHideCompletedDailyTasks').text("Tamamlananları Gizle");
}
// 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;
}
}
listenerControl();
$(document).ready(function() {
$(document).on('submit', '#scriptSettingsForm', function() {
var myNewCookies = {
buildingUpgrade: $('#script_BuildingUpgrade').is(":checked"),
townHall: $('#script_TownHall').is(":checked"),
premiumOffers: $('#script_PremiumOffers').is(":checked"),
dailyTasks: $('#script_DailyTasks').is(":checked"),
donation: $('#script_Donation').is(":checked"),
workshop: $('#script_Workshop').is(":checked"),
unitsInCity: $('#script_UnitsInCity').is(":checked"),
culturalExchange: $('#script_CulturalExchange').is(":checked"),
warehouse: $('#script_Warehouse').is(":checked"),
barracks: $('#script_Barracks').is(":checked"),
shipyard: $('#script_Shipyard').is(":checked")
}
eraseCookie("myIkaCookies");
setCookie("myIkaCookies", JSON.stringify(myNewCookies), 3);
window.location.reload();
return false;
});
});
/*
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();
*/
function createListener(flag, element_id, doneFunction){
if(!flag){
return;
}
var params;
if(element_id == ""){
params = {
parent: document.querySelector('body'),
recursive: false,
done: function() {
doneFunction();
}
}
}else{
params = {
id: element_id,
parent: document.querySelector('body'),
recursive: false,
done: function() {
doneFunction();
}
}
}
new MutationObserver(function(mutations) {
params.done();
}).observe(params.parent || document, {
childList: true
});
}
})();