var plugin_www_post_tracker_ru = { wwwref: false, authOk: false, auth: function (force) { if (!window.localStorage.getItem("plugin_www_post_tracker_ru_PHPSESSID") || force) { // var authURL="http://post-tracker.ru/login.php"; this.wwwref = window.open(encodeURI(authURL), '_blank', 'location=no'); // this.wwwref.addEventListener('loadstop', this.auth_jsinjection); // } else { plugin_www_post_tracker_ru.authOk=true; } }, auth_event_url: function (url) { var tmp=url_parser.get_args_cookie(url); // if (tmp['PHPSESSID'] && tmp['userid'] && tmp['securehash']) { // , plugin_www_post_tracker_ru.wwwref.close(); // window.localStorage.setItem("plugin_www_post_tracker_ru_PHPSESSID", tmp['PHPSESSID']); window.localStorage.setItem("plugin_www_post_tracker_ru_userid", tmp['userid']); window.localStorage.setItem("plugin_www_post_tracker_ru_securehash", tmp['securehash']); plugin_www_post_tracker_ru.authOk=true; } }, auth_cssinjection: function(){ plugin_www_post_tracker_ru.wwwref.insertCSS({code:".topline {display:none} .top {display:none} .logo {display:none} .menu {display:none} .counters {display:none} .bottom {display:none} .links {display:none} @-viewport {width: device-width; zoom: 1;"},function(){}); }, auth_jsinjection: function () { plugin_www_post_tracker_ru.auth_cssinjection(); // CSS , plugin_www_post_tracker_ru.wwwref.executeScript({ // JS code: "document.cookie;" }, function(arg) { plugin_www_post_tracker_ru.auth_event_url(arg); }); } }
var ajax = { init: function(){ return new XMLHttpRequest(); }, send: function(url,method,args,cookies,async,_callback){ var q=ajax.init(); q.open(method,url,async); q.onreadystatechange=function(){ if(this.readyState==4 && this.status==200) { _callback(this.responseText); } }; if (cookies) { q.setRequestHeader('Cookie',cookies); } if(method=='POST') { q.setRequestHeader('Content-type','application/x-www-form-urlencoded'); q.send(args); } else { q.send(null); } } }
, we are clearly logged out and you will have to go through the procedure again: get_content: function (async) { // var cookies="PHPSESSID="+window.localStorage.getItem("plugin_www_post_tracker_ru_PHPSESSID")+"; userid="+window.localStorage.getItem("plugin_www_post_tracker_ru_userid")+"; securehash="+window.localStorage.getItem("plugin_www_post_tracker_ru_securehash"); // cookie plugin_www_post_tracker_ru.dataReady=false; ajax.send("http://post-tracker.ru/my/",'GET',null,cookies,async,this._parse_content); // ajax }, _parse_content: function (data) { var wrapper=document.createElement('div'); // html , wrapper.innerHTML=data; plugin_www_post_tracker_ru._get_inside_data(wrapper,'trackcode,date,status,comment'); // , , }, _get_inside_data: function (wrapper,types) { var tmp=wrapper.getElementsByClassName('login')[0].innerHTML; // div login if (tmp=='<a href="/login.php"></a> <a href="/register.php"></a>') { // , plugin_www_post_tracker_ru.auth(true); } else { // plugin_www_post_tracker_ru.default_folder=wrapper.getElementsByTagName('input')[0].value; // ID , var types=types.split(","); for (var typeid in types) { // html- var tmp=wrapper.getElementsByClassName(types[typeid]); var id=0; for (var i in tmp) { if (tmp[i].innerHTML) { if (!plugin_www_post_tracker_ru.postdata[id]) plugin_www_post_tracker_ru.postdata[id]=new Array(); plugin_www_post_tracker_ru.postdata[id][(types[typeid])]=tmp[i].innerHTML.replace(/(\r\n|\n|\r)/gm,"").replace(/<\/?[^>]+>/gmi,"").replace(/^\s+|\s+$/gm,""); // , html id++; } } } plugin_www_post_tracker_ru.dataReady=true; show_list(); // } }, get_list: function () { // show_list() "" var tmp=new Array(); for (var i in plugin_www_post_tracker_ru.postdata) { tmp[i]="<b>"+plugin_www_post_tracker_ru.postdata[i]['trackcode']+"</b> "+plugin_www_post_tracker_ru.postdata[i]['comment']+"<br/>"+plugin_www_post_tracker_ru.postdata[i]['date']+" "+plugin_www_post_tracker_ru.postdata[i]['status']; } return tmp; }
show_list()
in this code will add blocks with a prepared html-inside of the div with the scroller (by the way, I recommend Overthrow and highly recommend iscroll-4 because of the terrible speed). put_trackCode: function(){ // " " var trackCode = prompt(" "); // if (trackCode) { this._put_trackCode_getPath(trackCode); // ( ), if (plugin_www_post_tracker_ru.default_path) { // , var comment = prompt(""); if (comment) { this._put_trackCode(trackCode,comment); // } } else { alert(" "); } } else { menuButtonHide(); // , } }, _put_trackCode_getPath: function (trackCode) { // var cookies="PHPSESSID="+window.localStorage.getItem("plugin_www_post_tracker_ru_PHPSESSID")+"; userid="+window.localStorage.getItem("plugin_www_post_tracker_ru_userid")+"; securehash="+window.localStorage.getItem("plugin_www_post_tracker_ru_securehash"); var data="act=getPathForm&trackcode="+encodeURIComponent(trackCode); ajax.send("http://post-tracker.ru/ajax/userTrackcodes.php",'POST',data,cookies,false,this._put_trackCode_getPath_result); }, _put_trackCode_getPath_result: function (data){ var wrapper=document.createElement('div'); // , html wrapper.innerHTML=data; var tmp=wrapper.getElementsByTagName('input'); // input if (tmp.length>0) { plugin_www_post_tracker_ru.default_path=tmp[0].value; // , }else{ plugin_www_post_tracker_ru.default_path=false; } }, _put_trackCode: function (trackCode,comment){ // , var cookies="PHPSESSID="+window.localStorage.getItem("plugin_www_post_tracker_ru_PHPSESSID")+"; userid="+window.localStorage.getItem("plugin_www_post_tracker_ru_userid")+"; securehash="+window.localStorage.getItem("plugin_www_post_tracker_ru_securehash"); var data="act=addTrackcodeAction&folderid="+plugin_www_post_tracker_ru.default_folder+"&trackcode="+encodeURIComponent(trackCode)+"&path="+plugin_www_post_tracker_ru.default_path+"&comment="+encodeURIComponent(comment); ajax.send("http://post-tracker.ru/ajax/userTrackcodes.php",'POST',data,cookies,false,this._put_trackCode_result); }, _put_trackCode_result: function(data){ // menuButtonHide(); // plugin_www_post_tracker_ru.get_content(true); // }
folderid =" + plugin_www_post_tracker_ru.default_folder + "& trackcode =" + encodeURIComponent (trackCode) + "& path =" + plugin_www_post_tracker_ru.default_path + "& comment =" + encodeURIComponent (comment); put_trackCode: function(){ // " " var trackCode = prompt(" "); // if (trackCode) { this._put_trackCode_getPath(trackCode); // ( ), if (plugin_www_post_tracker_ru.default_path) { // , var comment = prompt(""); if (comment) { this._put_trackCode(trackCode,comment); // } } else { alert(" "); } } else { menuButtonHide(); // , } }, _put_trackCode_getPath: function (trackCode) { // var cookies="PHPSESSID="+window.localStorage.getItem("plugin_www_post_tracker_ru_PHPSESSID")+"; userid="+window.localStorage.getItem("plugin_www_post_tracker_ru_userid")+"; securehash="+window.localStorage.getItem("plugin_www_post_tracker_ru_securehash"); var data="act=getPathForm&trackcode="+encodeURIComponent(trackCode); ajax.send("http://post-tracker.ru/ajax/userTrackcodes.php",'POST',data,cookies,false,this._put_trackCode_getPath_result); }, _put_trackCode_getPath_result: function (data){ var wrapper=document.createElement('div'); // , html wrapper.innerHTML=data; var tmp=wrapper.getElementsByTagName('input'); // input if (tmp.length>0) { plugin_www_post_tracker_ru.default_path=tmp[0].value; // , }else{ plugin_www_post_tracker_ru.default_path=false; } }, _put_trackCode: function (trackCode,comment){ // , var cookies="PHPSESSID="+window.localStorage.getItem("plugin_www_post_tracker_ru_PHPSESSID")+"; userid="+window.localStorage.getItem("plugin_www_post_tracker_ru_userid")+"; securehash="+window.localStorage.getItem("plugin_www_post_tracker_ru_securehash"); var data="act=addTrackcodeAction&folderid="+plugin_www_post_tracker_ru.default_folder+"&trackcode="+encodeURIComponent(trackCode)+"&path="+plugin_www_post_tracker_ru.default_path+"&comment="+encodeURIComponent(comment); ajax.send("http://post-tracker.ru/ajax/userTrackcodes.php",'POST',data,cookies,false,this._put_trackCode_result); }, _put_trackCode_result: function(data){ // menuButtonHide(); // plugin_www_post_tracker_ru.get_content(true); // }
Source: https://habr.com/ru/post/181610/
All Articles