NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name #_1_iframe_buttons // @namespace http://tampermonkey.net/ // @version 0.1.0 // @description try to take over the world! // @author You // @icon https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTf0UnJ9mqyjuAJTOk8pCs9-mJG94aNrf1lmKxvViy9jduVnPIk // @match http://uni4.xorbit.de/framesAAA.php // @match http://uni4.xorbit.de/leftmenu.php // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js // @match file:///opt/local/apache2/htdocs/local/html/_XOrbit/Frames/frames.php.html // @grant none // ==/UserScript== /* jshint -W097 */ // 'use strict'; // wenn aktiviert, ist kein zugriff auf die variablen moeglich!! alert('start'); //console.info( // document.URL + '\n' + // document.querySelector('html').innerHTML + '\n\n' + // window.frames.length //); if (document.URL.match('http://uni4.xorbit.de/leftmenu.php')) { // window.frameElement.scrolling = "yes"; // console.info( // "document.URL.match('http://uni4.xorbit.de/leftmenu.php'" + '\n' + // document.querySelector('html').innerHTML + '\n\n' // ); window['marchand_new'] = function(toDo) { met_zu_kris = 0.66666666666667; met_zu_deut = 0.33333333333333; kris_zu_met = 1.5; kris_zu_deut = 0.5; deut_zu_met = 3; deut_zu_kris = 2; if (toDo.match('name')) { alert('name: ' + toDo); win = document.querySelector('iframe').contentWindow.window; doc = document.querySelector('iframe').contentWindow.window.document; var s_get_ressName = doc.querySelector('#get_ressName').value; alert('s_get_ressName: ' + s_get_ressName); win['i1_name'] = doc.querySelectorAll('td')[3]; win['i1_kurs'] = doc.querySelectorAll('td')[5]; window['i2_name'] = doc.querySelectorAll('td')[6]; window['i2_kurs'] = doc.querySelectorAll('td')[8]; if (s_get_ressName.match('cristal')) { i1_name.innerHTML = 'Metall'; i1_kurs.innerHTML = met_zu_kris; i2_name.innerHTML = 'Deuterium'; i2_kurs.innerHTML = deut_zu_kris; i1.name = 'metal'; i2.name = 'deut'; } if (s_get_ressName.match('metal')) { i1_name.innerHTML = 'Kristall'; i1_kurs.innerHTML = kris_zu_met; i2_name.innerHTML = 'Deuterium'; i2_kurs.innerHTML = deut_zu_met; i1.name = 'cristal'; i2.name = 'deut'; } if (s_get_ressName.match('deut')) { i1_name.innerHTML = 'Metall'; i1_kurs.innerHTML = met_zu_deut; i2_name.innerHTML = 'Kristall'; i2_kurs.innerHTML = kris_zu_deut; i1.name = 'metal'; i2.name = 'cristal'; } } if (toDo.match('value')) { s_get_ressName = document.querySelector('#get_ressName').value; i1_val = document.querySelectorAll('input')[0].value; console.debug('i1_val: ' + i1_val); i2_val = document.querySelectorAll('input')[1].value; console.debug('i2_val: ' + i2_val); val_get_html = document.querySelector('#val_get'); console.debug('#val_get: ' + val_get_html); if (s_get_ressName.match('metal')) { i1_val = i1_val * kris_zu_met; i2_val = i2_val * deut_zu_met; console.debug('s_get_ressName_match__metal\n\n' + 'i1_val: ' + i1_val + '\n' + 'i2_val: ' + i2_val); } if (s_get_ressName.match('cristal')) { i1_val = i1_val * met_zu_kris; i2_val = i2_val * deut_zu_kris; } if (s_get_ressName.match('deut')) { i1_val = i1_val * met_zu_deut; i2_val = i2_val * kris_zu_deut; } i_val_get = parseInt(i1_val + i2_val).toLocaleString('de-DE'); console.debug('i_val_get: ' + i_val_get); if (isNaN(i1_val) || isNaN(i2_val)) { val_get_html.innerHTML = 'Eine Zahl!!!'; } else { val_get_html.innerHTML = i_val_get; console.debug('i_val_get: ' + i_val_get + '\n' + 'val_get_html.innerHTML: ' + val_get_html.innerHTML); } } } o_div = document.createElement('div'); o_div.id = 'id_o_div'; document.body.insertBefore(o_div, document.body.childNodes[0]); o_button = document.createElement('button'); o_button.type = 'button'; o_button.id = 'id_o_button'; o_button.innerHTML = 'reload'; o_button.setAttribute('onclick', 'javascript:reload_marchandHTML()'); o_div.appendChild(o_button); o_iframe = document.createElement('iframe'); o_iframe.id = 'id_o_iframe'; o_iframe.width = '600px'; o_iframe.heigth = '350px'; o_iframe.scrolling = 'yes'; o_iframe.src = 'http://uni4.xorbit.de/marchand.php'; o_div.appendChild(o_iframe); // document.getElementById('id_o_div').appendChild(o_button); document.getElementById('id_o_div').appendChild(o_iframe); var input_timer = document.createElement('input'); input_timer.id = 'id_input_timer'; reload_Hauptframe = function() { checkbox_active = o_checkbox_reloadHauptframe.checked; if (checkbox_active == true) { sleep(o_input_timerValue.value, top.Hauptframe.location.reload); } else { clearTimeout(id_timeout); } alert(this.id + '\t' + this.checked); } o_button_reloadHauptframe = document.createElement('button'); o_button_reloadHauptframe.type = 'button'; o_button_reloadHauptframe.id = 'id_o_button_reloadHauptframe'; o_button_reloadHauptframe.innerHTML = 'reload_Hauptframe'; o_button_reloadHauptframe.setAttribute('onclick', 'javascript:top.Hauptframe.location.reload()'); o_div.appendChild(o_button_reloadHauptframe); o_checkbox_reloadHauptframe = document.createElement('input'); o_checkbox_reloadHauptframe.type = 'checkbox'; o_checkbox_reloadHauptframe.id = 'id_o_checkbox_reloadHauptframe'; o_checkbox_reloadHauptframe.value = 0; o_checkbox_reloadHauptframe.setAttribute('onchange', 'javascript:reload_Hauptframe()'); o_div.appendChild(o_checkbox_reloadHauptframe); o_input_timerValue = document.createElement('input'); o_input_timerValue.type = 'text'; o_input_timerValue.id = 'id_o_input_timerValue'; o_input_timerValue.size = 3; o_input_timerValue.maxlength = 3; o_input_timerValue.value = 30; o_div.appendChild(o_input_timerValue); label = document.createElement('label'); label.htmlFor = 'id_o_checkbox_reloadHauptframe'; label.appendChild(document.createTextNode(' sek.')); o_div.appendChild(label); sHTML = '' + '<form id="marchand" action="marchand.php" method="post">' + ' \n' + ' <table>' + ' \n' + ' <tr>' + ' \n' + ' <td>' + ' \n' + ' <select id="get_ressName" name="ress" onchange=marchand_new("name")>' + '\n' + ' <option id="get_met" value="metal">Metall</option>' + '\n' + ' <option id="get_kris" value="cristal">Kristall</option>' + '\n' + ' <option id="get_deut" value="deut">Deuterium</option>' + '\n' + ' </select>' + ' \n' + ' </td>' + ' \n' + ' <td>' + '<span id="val_get"></span>' + '</td>' + ' <td>' + '1' + '</td>' + ' </tr>' + ' \n' + ' <tr>' + ' \n' + ' <td>' + 'Kristall' + '</td>' + ' <td>' + ' \n' + ' <input id="i1" name="cristal" type="text" value="0" onkeyup=marchand_new("value")>' + ' \n' + ' </td>' + ' \n' + ' <td>' + '1.5' + '</td>' + ' </tr>' + ' \n' + ' <tr>' + ' \n' + ' <td>' + 'Deuterium' + '</td>' + ' <td>' + ' \n' + ' <input id="i2" name="deut" type="text" value="0" onkeyup=marchand_new("value")>' + ' \n' + ' </td>' + ' \n' + ' <td>' + '3' + '</td>' + ' </tr>' + ' \n' + ' <tr>' + ' \n' + ' <td>' + ' \n' + ' <input type="submit" value="tausche">' + ' \n' + ' </td>' + ' \n' + ' </tr>' + ' \n' + ' </table>' + ' \n' + '</form>' + ' \n' create_marchand = function() { alert('create_marchand'); /* console.log( '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' + '\n' + frames + '\n' + frames.length + '\n' + frames[0] + '\n' + document.querySelector('html').innerHTML ) console.debug( '++++++++++++++++++++++++++++++++++++++++++++++++' + '\n' + frames[0].document.querySelector('html').innerHTML ) */ } create_marchand(); reload_marchandHTML = function() { res_timer = document.querySelector('iframe').contentWindow.window['restimer']; document.querySelector('iframe').contentWindow.window.clearInterval(res_timer); window['id_o_iframe'].contentWindow.window['marchand_new'] = function(toDo) { doc = document.querySelector('iframe').contentWindow.window.document; // console.debug(doc.body.innerHTML); var met_zu_kris = 0.66666666666667; var met_zu_deut = 0.33333333333333; var kris_zu_met = 1.5; var kris_zu_deut = 0.5; var deut_zu_met = 3; var deut_zu_kris = 2; if (toDo.match('name')) { var s_get_ressName = doc.querySelector('#get_ressName').value; console.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' + '\n' + // 'doc.body.innerHTML: ' + '\n' + doc.body.innerHTML + '\n' + 'document.body.innerHTML: ' + '\n' + document.body.innerHTML + '\n' ) i1_name = document.querySelectorAll('td')[3]; i1_kurs = document.querySelectorAll('td')[5]; i2_name = document.querySelectorAll('td')[6]; i2_kurs = document.querySelectorAll('td')[8]; if (s_get_ressName.match('cristal')) { i1_name.innerHTML = 'Metall'; i1_kurs.innerHTML = met_zu_kris; i2_name.innerHTML = 'Deuterium'; i2_kurs.innerHTML = deut_zu_kris; doc.querySelector('#i1').name = 'metal'; doc.querySelector('#i2').name = 'deut'; // alert('val_met_vorhanden: ' + val_met_vorhanden); } if (s_get_ressName.match('metal')) { i1_name.innerHTML = 'Kristall'; i1_kurs.innerHTML = kris_zu_met; i2_name.innerHTML = 'Deuterium'; i2_kurs.innerHTML = deut_zu_met; doc.querySelector('#i1').name = 'cristal'; doc.querySelector('#i2').name = 'deut'; } if (s_get_ressName.match('deut')) { i1_name.innerHTML = 'Metall'; i1_kurs.innerHTML = met_zu_deut; i2_name.innerHTML = 'Kristall'; i2_kurs.innerHTML = kris_zu_deut; doc.querySelector('#i1').name = 'metal'; doc.querySelector('#i2').name = 'cristal'; } } if (toDo.match('value')) { s_get_ressName = doc.querySelector('#get_ressName').value; i1_val = doc.querySelectorAll('input')[0].value; console.debug('i1_val: ' + i1_val); window['i2_val'] = doc.querySelectorAll('input')[1].value; console.debug('i2_val: ' + i2_val); val_get_html = doc.querySelector('#val_get'); console.debug('#val_get: ' + val_get_html); if (s_get_ressName.match('metal')) { i1_val = i1_val * kris_zu_met; i2_val = i2_val * deut_zu_met; console.info('s_get_ressName_match__metal\t\t' + 'i1_name: ' + i1_val + '\t' + 'i2_val: ' + i2_val); } if (s_get_ressName.match('cristal')) { i1_val = i1_val * met_zu_kris; i2_val = i2_val * deut_zu_kris; } if (s_get_ressName.match('deut')) { i1_val = i1_val * met_zu_deut; i2_val = i2_val * kris_zu_deut; } i_val_get = parseInt(i1_val + i2_val).toLocaleString('de-DE'); console.debug('i_val_get: ' + i_val_get); if (isNaN(i1_val) || isNaN(i2_val)) { val_get_html.innerHTML = 'Eine Zahl!!!'; } else { val_get_html.innerHTML = i_val_get; console.debug('i_val_get: ' + i_val_get + '\n' + 'val_get_html.innerHTML: ' + val_get_html.innerHTML); } } }; document.querySelector('iframe').contentWindow.document.body.innerHTML = sHTML; insert_css(); getHTML = function(select, url) { jQuery = window['jQuery']; console.debug("document.querySelector('iframe').contentWindow.document" + '\n' + document.querySelector( 'iframe').contentWindow.document.body.innerHTML); doc = document.querySelector('iframe').contentWindow.document || frames[0].window['id_o_iframe'].contentWindow .document; selector = doc.querySelector(select); jQuery(selector).load(url); } ajax_get = function(url) { $ = window['jQuery']; var parser = new DOMParser(); jqxhr = $.get(url, function(data) {}) .done(function(data) { html = parser.parseFromString(data, 'text/html'); insert_values(html); }) .fail(function(data) { alert("error:\n" + data); }) } ajax_get('http://uni4.xorbit.de/overview.php'); window['insert_values'] = function(dom) { window['doc'] = window['id_o_iframe'].contentWindow.document; html_table_rohstoffe = '' + ' <table>' + ' \n' + ' <tbody>' + ' \n' + ' <tr>' + ' \n' + ' <th id="val_met_vorhanden"></th>' + ' \n' + ' <th></th>' + ' \n' + ' <th id="val_met_umgewandelt"></th>' + ' \n' + ' </tr>' + ' \n' + ' <tr>' + ' \n' + ' <th id="val_kris_vorhanden"></th>' + ' \n' + ' <th></th>' + ' \n' + ' <th id="val_kris_umgewandelt"></th>' + ' \n' + ' </tr>' + ' \n' + ' <tr>' + ' \n' + ' <th id="val_deut_vorhanden"></th>' + ' \n' + ' <th></th>' + ' \n' + ' <th id="val_deut_umgewandelt"></th>' + ' \n' + ' </tr>' + ' \n' + ' </tbody>' + ' \n' + ' </table>' + ' \n' window['div_rohstoffe'] = doc.createElement('div'); window['div_met'] = doc.createElement('div'); div_met.id = 'div_met'; window['div_kris'] = doc.createElement('div'); div_kris.id = 'div_kris'; window['div_deut'] = doc.createElement('div'); div_deut.id = 'div_deut'; // window['id_o_iframe'].contentWindow.document.body.appendChild(div_met); // window['id_o_iframe'].contentWindow.document.body.appendChild(div_kris); // window['id_o_iframe'].contentWindow.document.body.appendChild(div_deut); window['id_o_iframe'].contentWindow.document.body.appendChild(div_rohstoffe); div_rohstoffe.innerHTML = html_table_rohstoffe; window['met_html'] = dom.getElementById('met').innerHTML; window['met'] = met_html.replace(/\./g, '').match(/\d+/); // doc.querySelector('#val_met_vorhanden').innerHTML = met_html; // + '________' + met; window['kris_html'] = dom.getElementById('cry').innerHTML; window['kris'] = kris_html.replace(/\./g, '').match(/\d+/); // doc.querySelector('#val_kris_vorhanden').innerHTML = kris_html; // + '________' + kris; window['deut_html'] = dom.getElementById('deut_rechner').innerHTML; window['deut'] = deut_html.replace(/\./g, '').match(/\d+/); // doc.querySelector('#val_deut_vorhanden').innerHTML = deut_html; // + '________' + deut; // sel_planeten = frames[1].document.querySelector('#pselector'); } } insert_css = function() { console.log(frames.length); console.log("window['id_o_iframe'].contentWindow.document: \n" + window['id_o_iframe'].contentWindow.document); doc = window['id_o_iframe'].contentWindow.document; node_HTML = doc.createTextNode(sHTML); head = doc.head || doc.querySelector('head'); style = doc.createElement('style'); style.type = "text/css"; var css = '\n' + 'table { font-size: 11px; color: white; }' + '\n' + 'select { font-size: 11px; }' style.appendChild(doc.createTextNode(css)); head.appendChild(style); console.info(css); } }; (function() { console.debug('______START: ====> ' + getTime()); // insert_script('http://localhost/local/javascript/jquery.js', 'jquery'); fn_startNow(); console.debug('________END: ====> ' + getTime()); })() function insert_script(url_src, script_name) { scr = document.createElement('script'); scr.src = url_src; scr.id = script_name; scr.type = 'text/javascript'; try { document.getElementsByTagName('head')[0].appendChild(scr); window.setTimeout(function() { script_inserted = document.getElementById('jquery'); console.info('\n.\n') if (script_inserted != null) { // jquery-js-file wurde geladen und kann jetzt verwendet werden fn_startNow(); } else { console.debug('\n@@@@@@@@@@@@@@@@@@@@@@|===> wasnt defined') } }, 250); } catch (e) { console.log('\t\t====> e: ->\t' + e); } } function fn_startNow() { console.log('\t########################\n' + '====> fn_startNow: _#_START___' + '++++++\n' + '_____#####'); createArray(); create_iframe('750px', '600px', 'center', 'before'); // for debugging only console.debug('\t\t==> fn_startNow\n') console.log('\t########################\n' + '====> fn_startNow: _#__END____' + '++++++\n' + '_____#####'); } function getTime() { var time_tmp = new Date(); var i_hours = time_tmp.getHours(); var i_minutes = time_tmp.getMinutes(); var i_seconds = time_tmp.getSeconds(); if (i_seconds.toString().length == 1) { i_seconds = '0' + i_seconds }; if (i_minutes.toString().length == 1) { i_minutes = '0' + i_minutes }; if (i_hours.toString().length == 1) { i_hours = '0' + i_hours }; var s_time = i_hours + ':' + i_minutes + ':' + i_seconds; return s_time; } window['sleep'] = function(sleeptime, reloadPage) { timeout = 1; console.debug('_____#sleeptime:___->_' + sleeptime + '#________====> ' + getTime()); if (sleeptime <= 0) { console.debug('\t-> Zeit ist abgelaufen <-\t'); timeout = 0; // top.Hauptframe.location.reload(); reloadPage(); // return; } else {} sleeptime = sleeptime - 1; console.log('@@@@@@@@@@@ sleeptime: -> ' + sleeptime); window['val_sleeptime'] = sleeptime; if (timeout == 1) { window['id_timeout'] = window.setTimeout("sleep(val_sleeptime);", 999); console.debug('fn_sleep___id:__' + id_timeout + '\t' + 'val_sleeptime: ' + val_sleeptime); } } function edit_iframe() { iframe_1.height = height; iframe_1.width = width; } window['fn_leer'] = function() {} function create_iframe() { var iframe_max = parseInt(document.querySelectorAll('iframe').length); var iframe_new = parseInt(iframe_max + 1); window['iframe_t' + iframe_new] = document.createElement("iframe"); eval('iframe_t' + iframe_new + '.id = "iframe_t" + iframe_new'); eval('iframe_t' + iframe_new + '.name = "iframe_t" + iframe_new'); eval('iframe_t' + iframe_new + '.class = "iframe_t" + iframe_new'); eval('iframe_t' + iframe_new + '.width = "500px"'); eval('iframe_t' + iframe_new + '.height = "250px"'); document.body.appendChild(eval('iframe_t' + iframe_new)); return (eval('iframe_t' + iframe_new)); } function create_iframe_old(width, height, pos, pos2) { var iframe_max = parseInt(document.querySelectorAll('iframe').length); var iframe_new = parseInt(iframe_max + 1); try { window['height'] = '500px'; window['width'] = '300px'; console.debug('######____\t==> URL: ' + document.URL); window.frameElement.contentWindow.document.body.innerHTML; window['iframe_' + iframe_new] = document.createElement("iframe"); window['iframe_' + iframe_new] + '.id = iframe_' + iframe_new; window['iframe_' + iframe_new] + '.name = iframe_' + iframe_new; window['iframe_' + iframe_new] + '.class = iframe_' + iframe_new; window['iframe_' + iframe_new] + '.width = ' + width; window['iframe_' + iframe_new] + '.height = ' + height; console.debug('window: \t|\t' + window); console.debug('window.frames: \t|\t' + window.frames); console.debug('window.frames.length: \t|\t' + window.frames.length); console.debug('window.frames[0]: \t|\t' + window.frames[0]); console.debug('window.frames[0].contentWindow.document: \t|\t' + window.frames[0].contentWindow.document); var node = window.frames[0].document.getElementsByTagName('center')[0]; var childNode = node.childNodes[0]; // document.body.appendChild( eval('iframe_' + iframe_new) ); if (pos2 == 'before') { Node.insertBefore(eval('iframe_' + iframe_new), childNode); } if (pos2 == 'after') { Node.appendChild(eval('iframe_' + iframe_new)); } } catch (e) { console.error('\n\n\n\t\t##############========> e: ' + e) } } function createArray() { console.debug('##############_____-> function createArray()'); window['a_planeten'] = new Array(); a_planeten[0] = 20; a_planeten[1] = 24; a_planeten[2] = 27; a_planeten[3] = 97; a_planeten[4] = 99; a_planeten[5] = 106; a_planeten[6] = 122; a_planeten[7] = 125; a_planeten[8] = 360; a_planeten[9] = 431; a_planeten[10] = 432; a_planeten[11] = 673; $(a_planeten).each(function(i_test) { console.info('===> : ' + i_test + ' -> ' + this + '\n') }) }