trying alternative startup code - actually checks for PLAYER being set - and just accesses it directly rather than messing around parsing <script> tags.
This commit is contained in:
parent
0ec6805c34
commit
2f781dab81
18
main.js
18
main.js
@ -27,18 +27,11 @@ window.iitcBuildDate = '@@BUILDDATE@@';
|
||||
window.onload = function() {};
|
||||
document.body.onload = function() {};
|
||||
|
||||
// rescue user data from original page
|
||||
var scr = document.getElementsByTagName('script');
|
||||
for(var x in scr) {
|
||||
var s = scr[x];
|
||||
if(s.src) continue;
|
||||
if(s.type !== 'text/javascript') continue;
|
||||
var d = s.innerHTML.split('\n');
|
||||
break;
|
||||
}
|
||||
|
||||
//originally code here parsed the <Script> tags from the page to find the one that defined the PLAYER object
|
||||
//however, that's already been executed, so we can just access PLAYER - no messing around needed!
|
||||
|
||||
if(!d) {
|
||||
if (!window.PLAYER) {
|
||||
// page doesn’t have a script tag with player information.
|
||||
if(document.getElementById('header_email')) {
|
||||
// however, we are logged in.
|
||||
@ -53,11 +46,6 @@ if(!d) {
|
||||
}
|
||||
|
||||
|
||||
for(var i = 0; i < d.length; i++) {
|
||||
if(!d[i].match('var PLAYER = ')) continue;
|
||||
eval(d[i].match(/^var /, 'window.'));
|
||||
break;
|
||||
}
|
||||
// player information is now available in a hash like this:
|
||||
// window.PLAYER = {"ap": "123", "energy": 123, "available_invites": 123, "nickname": "somenick", "team": "ENLIGHTENED||RESISTANCE"};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user