0
I’m doing some Javascript studies and would like to know how to make my browser create a window, and perform a number of functions as soon as it is fully charged.
I’m running all the codes through the browser console
//Pretendo fazer um loop para que essas funções rodem até que o array acabe.
function configCustomPost (i) {
//Caso a pagina esteja carregada execute
redirectFunc(i);
//Isso gera uma troca de pagina, então quando a nova pagina estiver carregada execute
setTimeout(function(){firstClick()} , 10000);
//Isso tbm gera uma troca de pagina, então quando a nova pagina estiver carregada execute
setTimeout(function(){secondClick()} , 30000);
}
Complete:
i = 0;
href_init = 'http://localhost/novosite/wp-admin/admin.php?page=pods-add-new' ;
post_sing = ['a','b','c','d','e','f','g','h','i'];
post_plur = ['a','b','c','d','e','f','g','h','i'];
menu_pai = "pods-settings-unidade_1";
var k = window.open(href_init);
function configCustomPost (i) {
redirectFunc(i);
setTimeout(function(){firstClick()} , 10000);
setTimeout(function(){secondClick()} , 30000);
setTimeout(function(){},40000);
}
function redirectFunc(i){
sing = post_sing[i];
plur = post_plur[i];
k.location = href_init;
}
function firstClick(){
k.jQuery("a[href='#pods-wizard-create']").click();
k.jQuery("#pods-form-ui-create-label-singular").val(sing);
k.jQuery("#pods-form-ui-create-label-plural").val(plur);
k.jQuery("#pods-form-ui-create-name").val(plur);
k.jQuery("#pods-wizard-next").click();
}
function secondClick() {
k.jQuery("[href='#pods-advanced']").click();
k.jQuery("#pods-form-ui-supports-author").click();
k.jQuery("#pods-form-ui-supports-thumbnail").click();
k.jQuery("#pods-form-ui-supports-excerpt").click();
k.jQuery("#pods-form-ui-supports-trackbacks").click();
k.jQuery("#pods-form-ui-supports-custom-fields").click();
k.jQuery("#pods-form-ui-supports-comments").click();
k.jQuery("#pods-form-ui-supports-revisions").click();
k.jQuery("#pods-form-ui-supports-page-attributes").click();
k.jQuery("#pods-form-ui-supports-post-formats").click();
k.jQuery("#pods-form-ui-built-in-taxonomies-category").click();
//
k.jQuery("[href='#pods-admin-ui']").click();
if((sing).length > 30){
k.jQuery("#pods-form-ui-description").val(sing);
}
k.jQuery("#pods-form-ui-show-in-admin-bar").click();
k.jQuery("#pods-form-ui-menu-location-custom").val(menu_pai);
//
k.jQuery("[href='#pods-labels']").click();
k.jQuery("#pods-form-ui-label-all-items").val('Posts '+sing);
k.jQuery(".button-primary").click();
i++;
}
It didn’t work, I tested it here : Function test() { k. Location = href_init; Document.addeventlistener('Domcontentloaded', Function(){ console.log('oi'); }, false); }
– Kaue Alves