Created
February 1, 2010 13:31
-
-
Save filiptepper/291691 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<script> | |
function start(){ | |
localStorage['script'] = ''; | |
window.odswierzaj = false; | |
chrome.browserAction.setBadgeText({text: ""}); | |
window.bliplogin = localStorage['bliplogin']; | |
window.bliphaslo = localStorage['bliphaslo']; | |
window.dzialanie = localStorage['dzialanie']; | |
window.avatary = 'tak'; | |
if(localStorage['avatary']) { | |
if(localStorage['avatary']=='tak') { | |
window.avatary = 'tak'; | |
} else { | |
window.avatary = 'nie'; | |
} | |
} else { | |
window.avatary = 'nie'; | |
} | |
localStorage['tresc'] = 'Trwa ładowanie...'; | |
//alert(bliplogin+' '+bliphaslo+' '+dzialanie); | |
if (bliplogin && bliphaslo != '' && dzialanie != '' && bliplogin && bliphaslo && dzialanie) { | |
test_autoryzacji(); | |
} | |
else { | |
localStorage['tresc'] = '<a href="javascript:go(\'chrome-extension://dbkfafjifcblbdpcglenlogeahahmddd/options.html\');">Podaj wszystkie ustawienia</a>'; | |
chrome.browserAction.setBadgeText({text: "error"}); | |
} | |
} | |
function test_autoryzacji(){ | |
localStorage['tresc'] = 'Trwa sprawdzanie poprawności wprowadzonych danych...'; | |
var xhr = new XMLHttpRequest(); | |
//params = 'login='+window.bliplogin+'&haslo='+window.bliphaslo; | |
//xhr.open("POST", "http://kuba300.webd.pl/blipproxy/?ver=3&co=dashboard&limit=1", true); | |
xhr.open("GET", "http://api.blip.pl/dashboard?limit=1", true); | |
xhr.setRequestHeader('Authorization', 'Basic ' + window.btoa(window.bliplogin + ':' + window.bliphaslo)); | |
//xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
xhr.setRequestHeader("Accept", "application/json"); | |
xhr.setRequestHeader("X-Blip-API", "0.02"); | |
//xhr.send(params); | |
xhr.send(); | |
xhr.onreadystatechange = function(){ | |
if (xhr.readyState == 4) { | |
if (xhr.status == 200) { | |
localStorage['tresc'] = 'Potwiedzono poprawność danych, czekaj...'; | |
show(); | |
} else { | |
//alert(xhr.status); | |
localStorage['tresc'] = 'Błąd: '+xhr.status; | |
chrome.browserAction.setBadgeText({text: "error"}); | |
} | |
} | |
} | |
} | |
function show() { | |
bliplogin = window.bliplogin; | |
bliphaslo = window.bliphaslo; | |
dzialanie = window.dzialanie; | |
if(dzialanie=='blip') { | |
//html = '<img src="blip60.png" /><input id="blipniecie" type=text size="50" /><button onclick="blipnij();" >Blipnij</button>'; | |
html = '<table border="0"><tr><td colspan="1" rowspan="2" style="width: 65px;"><a href="javascript:go(\'http://blip.pl/dashboard\')"><img src="blip60.png" /></a></td><td><input id="blipniecie" onkeyup="blips_odliczanie(event);" type=text size="50" /><button onclick="blipnij();" >Blipnij</button></td></tr><tr><td class="podpis"><a href="javascript:czysc();">wyczyść</a>; wpisano znaków: <span id="pozostaloznakow">0</div></td></tr></table>'; | |
localStorage['tresc'] = html; | |
localStorage['script'] = 'size(480);'; | |
} else if(dzialanie=='kokpit') { | |
localStorage['script'] = 'size(480);'; | |
//html = '<center><img src="blip60.png" /><input id="blipniecie" type=text size="50" /><button onclick="blipnij();" >Blipnij</button></center><br/><br/><div id="blips"></div>'; | |
//html = '<table border="0"><tr><td colspan="1" rowspan="2" style="width: 65px"><img src="blip60.png" /></td><td><input id="blipniecie" type=text size="50" /><button onclick="blipnij();" >Blipnij</button></td></tr><tr><td>123test123</td></tr></table>'; | |
html = '<table border="0"><tr><td colspan="1" rowspan="2" style="width: 65px;"><a href="javascript:go(\'http://blip.pl/dashboard\')"><img src="blip60.png" /></a></td><td><input id="blipniecie" onkeyup="blips_odliczanie(event);" type=text size="50" /></textarea><button onclick="blipnij();" >Blipnij</button></td></tr><tr><td class="podpis"><a href="javascript:czysc();">wyczyść</a>; wpisano znaków: <span id="pozostaloznakow">0</div></td></tr></table><br/><div style="height: 500px; overflow: scroll; overflow-x: hidden;" id="blips"></div>'; | |
localStorage['tresc'] = html; | |
localStorage['blips'] = 'Trwa ładowanie kokpitu...'; | |
window.lastid = 0; | |
window.ile = 0; | |
window.odswierzaj = true; | |
blips_odswierz(); | |
setInterval("blips_odswierz();", 30000); | |
} else { | |
localStorage['tresc'] = 'error'; | |
} | |
} | |
function clear() { | |
window.setTimeout(clear2, 10000); | |
} | |
function clear2() { | |
chrome.browserAction.setBadgeText({text: ""}); | |
} | |
function blips_odswierz() { | |
if (window.odswierzaj) { | |
var xhr = new XMLHttpRequest(); | |
if(window.avatary == 'tak') { | |
url = 'http://api.blip.pl/dashboard?limit=10&include=pictures,user,user[avatar],recipient,recipient[avatar]'; | |
} else { | |
url = 'http://api.blip.pl/dashboard?limit=10&include=pictures'; | |
} | |
xhr.open("GET", url, true); | |
xhr.setRequestHeader('Authorization', 'Basic ' + window.btoa(window.bliplogin + ':' + window.bliphaslo)); | |
//xhr.setRequestHeader("Accept", "application/json"); | |
xhr.setRequestHeader("Accept", "application/json"); | |
xhr.setRequestHeader("X-Blip-API", "0.02"); | |
xhr.send(); | |
xhr.onreadystatechange = function(){ | |
if (xhr.readyState == 4) { | |
if (xhr.status == 200) { | |
blips_dodaj(xhr.responseText); | |
} | |
else { | |
//alert(xhr.status); | |
//localStorage['blips'] = 'Podczas odświeżania wystąpił błąd '+xhr.status; | |
//chrome.browserAction.setBadgeText({text: "error"}); | |
} | |
} | |
} | |
} | |
} | |
function blips_dodaj(blips) { | |
//localStorage['blips'] = blips; | |
licznik = 0; | |
tresc = ''; | |
ile = window.ile; | |
lastid = window.lastid; | |
tablica = JSON.parse(blips); | |
while (licznik < 10) { | |
nr = 9 - licznik; | |
id = tablica[nr]['id']; | |
autor = str_replace('/users/', '', tablica[nr]['user_path']); | |
if(window.avatary == 'tak') { | |
autor = tablica[nr]['user']['login']; | |
} else { | |
autor = str_replace('/users/', '', tablica[nr]['user_path']); | |
} | |
if (window.avatary == 'tak') { | |
if(tablica[nr]['user']['avatar']) { | |
user_img = 'http://blip.pl'+tablica[nr]['user']['avatar']['url_50']; | |
} else { | |
user_img = 'http://static0.blip.pl/images/nn_pico.png'; | |
} | |
} | |
if (tablica[nr]['type'] == 'Status') { | |
if (window.avatary == 'tak') { | |
dodaj = '<table class="tabblip"><tr><td style="vertical-align: top;"><a href="javascript:go(\'http://blip.pl/users/'+autor+'/dashboard\')"><img src="'+user_img+'" /></a></td><td style="vertical-align: top;">'; | |
} else { | |
dodaj = ''; | |
} | |
dodaj += '<span class="autor"><a href="javascript:go(\'http://blip.pl/users/'+autor+'/dashboard\')">' + autor + '</a></span>: ' + tablica[nr]['body']; | |
dodaj += ' <a class="opcjelink" href="javascript:void(0)" onclick="return showmenu_status(\''+id+'\', \''+autor+'\');" onmouseout="return nd()">[opcje]</a>'; | |
if(tablica[nr]['pictures']) {dodaj += ' <a class="obrlink" href="javascript:go(\''+tablica[nr]['pictures'][0]['url']+'\');">[obrazek]</a>';} | |
if (window.avatary == 'tak') { | |
dodaj += '</td></tr></table>'; | |
} | |
} | |
else if (tablica[nr]['type'] == 'DirectedMessage') { | |
if(window.avatary == 'tak') { | |
odbiorca = tablica[nr]['recipient']['login']; | |
} else { | |
odbiorca = str_replace('/users/', '', tablica[nr]['recipient_path']); | |
} | |
if (window.avatary == 'tak') { | |
if(tablica[nr]['recipient']['avatar']) { | |
odb_img = 'http://blip.pl'+tablica[nr]['recipient']['avatar']['url_50']; | |
} else { | |
odb_img = 'http://static0.blip.pl/images/nn_pico.png'; | |
} | |
} | |
if (window.avatary == 'tak') { | |
dodaj = '<table class="tabblip"><tr><td style="width: 105px; vertical-align: top;"><a href="javascript:go(\'http://blip.pl/users/'+autor+'/dashboard\')"><img src="'+user_img+'" /></a> <img src="'+odb_img+'" /></td><td style="vertical-align: top;">'; | |
} else { | |
dodaj = ''; | |
} | |
dodaj += '<span class="nadawca"><a href="javascript:go(\'http://blip.pl/users/'+autor+'/dashboard\')">' + autor + '</a></span> > <span class="odbiorca">' + odbiorca + '</span>: ' + tablica[nr]['body']; | |
dodaj += ' <a class="opcjelink" href="javascript:void(0)" onclick="return showmenu_direct(\''+id+'\', \''+autor+'\');" onmouseout="return nd()">[opcje]</a>'; | |
if(tablica[nr]['pictures']) {dodaj += ' <a class="obrlink" href="javascript:go(\''+tablica[nr]['pictures'][0]['url']+'\');">[obrazek]</a>';} | |
if (window.avatary == 'tak') { | |
dodaj += '</td></tr></table>'; | |
} | |
} | |
else if (tablica[nr]['type'] == 'PrivateMessage') { | |
if(window.avatary == 'tak') { | |
odbiorca = tablica[nr]['recipient']['login']; | |
} else { | |
odbiorca = str_replace('/users/', '', tablica[nr]['recipient_path']); | |
} | |
if (window.avatary == 'tak') { | |
if(tablica[nr]['recipient']['avatar']) { | |
odb_img = 'http://blip.pl'+tablica[nr]['recipient']['avatar']['url_50']; | |
} else { | |
odb_img = 'http://static0.blip.pl/images/nn_pico.png'; | |
} | |
} | |
if (window.avatary == 'tak') { | |
dodaj = '<table class="tabblip"><tr><td style="width: 105px; vertical-align: top;"><a href="javascript:go(\'http://blip.pl/users/'+autor+'/dashboard\')"><img src="'+user_img+'" /></a> <img src="'+odb_img+'" /></td><td style="vertical-align: top;">'; | |
} else { | |
dodaj = ''; | |
} | |
dodaj += '<span class="nadawca"><a href="javascript:go(\'http://blip.pl/users/'+autor+'/dashboard\')">' + autor + '</a></span> >> <span class="odbiorca">' + odbiorca + '</span>: ' + tablica[nr]['body']; | |
dodaj += ' <a class="opcjelink" href="javascript:void(0)" onclick="return showmenu_priv(\''+id+'\', \''+autor+'\');" onmouseout="return nd()">[opcje]</a>'; | |
if(tablica[nr]['pictures']) {dodaj += ' <a class="obrlink" href="javascript:go(\''+tablica[nr]['pictures'][0]['url']+'\');">[obrazek]</a>';} | |
if (window.avatary == 'tak') { | |
dodaj += '</td></tr></table>'; | |
} | |
} | |
else if (tablica[nr]['type'] == 'Notice') { | |
dodaj = '(i) ' + tablica[nr]['body']; | |
} else if(tablica[nr]['type'] == 'UpdateTip') { | |
dodaj = '(i) ' + tablica[nr]['body']; | |
} | |
if(id>lastid) { | |
ile++; | |
lastid = id; | |
} | |
dodaj = wiadomosc(dodaj); | |
dodaj = '<div class="blipcale">'+dodaj+'</div>'; | |
tresc = dodaj+tresc; | |
licznik++; | |
} | |
localStorage['blips'] = tresc; | |
window.lastid = lastid; | |
window.ile = ile | |
if (ile>0) { | |
chrome.browserAction.setBadgeText({text: ile.toString()}); | |
} | |
} | |
function explode(delimiter,string,limit){var emptyArray={0:''};if(arguments.length<2||typeof arguments[0]=='undefined'||typeof arguments[1]=='undefined') | |
{return null;} | |
if(delimiter===''||delimiter===false||delimiter===null) | |
{return false;} | |
if(typeof delimiter=='function'||typeof delimiter=='object'||typeof string=='function'||typeof string=='object') | |
{return emptyArray;} | |
if(delimiter===true){delimiter='1';} | |
if(!limit){return string.toString().split(delimiter.toString());}else{var splitted=string.toString().split(delimiter.toString());var partA=splitted.splice(0,limit-1);var partB=splitted.join(delimiter.toString());partA.push(partB);return partA;}} | |
function str_replace(search,replace,subject,count){var i=0,j=0,temp='',repl='',sl=0,fl=0,f=[].concat(search),r=[].concat(replace),s=subject,ra=r instanceof Array,sa=s instanceof Array;s=[].concat(s);if(count){this.window[count]=0;} | |
for(i=0,sl=s.length;i<sl;i++){if(s[i]===''){continue;} | |
for(j=0,fl=f.length;j<fl;j++){temp=s[i]+'';repl=ra?(r[j]!==undefined?r[j]:''):r[0];s[i]=(temp).split(f[j]).join(repl);if(count&&s[i]!==temp){this.window[count]+=(temp.length-s[i].length)/f[j].length;}}} | |
return sa?s:s[0];} | |
function wiadomosc(msg) { | |
msg = msg.replace(new RegExp('http://rdir\.pl\/([0-9a-zA-Z]+)', 'g'), '<a class="link" href="http://rdir.pl/$1" target="_blank">[link]</a>'); | |
msg = msg.replace(new RegExp('http://blip\.pl\/s\/([0-9]+)', 'g'), '<a class="blipniecie" href="javascript:blipniecie_cytat(\'$1\');" >[blip]</a>'); | |
msg = msg.replace(new RegExp('http://blip\.pl\/dm\/([0-9]+)', 'g'), '<a class="blipniecie" href="javascript:blipniecie_cytat(\'$1\');" >[blip-dm]</a>'); | |
msg = msg.replace(new RegExp('http://blip\.pl\/pm\/([0-9]+)', 'g'), '<a class="blipniecie" href="http://blip.pl/pm/$1" target="_blank" >[blip-pm]</a>'); | |
msg = msg.replace(new RegExp('#([0-9a-zA-Z-_ąĄćĆęĘłŁńŃóÓŚśżŻźŹ]+)', 'g'), '<a class="tag" href="http://blip.pl/tags/$1" target="_blank" >#$1</a>'); | |
msg = msg.replace(new RegExp('([0-9a-zA-Z_.-]+)@([0-9a-zA-Z-]+).([a-zA-Z]+)', 'g'), '<a class="email" href="mailto:$1@$2.$3">[email]</a>'); | |
//msg = str_replace('^', '%@@%', msg); | |
msg = msg.replace(new RegExp('\\^([0-9a-zA-Z-_]+)', 'g'), '<a class="wzmianka" href="http://blip.pl/users/$1/dashboard" target="_blank">^$1</a>'); | |
//msg = str_replace('%@@%', '^', msg); | |
//msg = str_replace('youtube.com/watch?v', 'youtube.com/watch%v', msg); | |
msg = msg.replace(new RegExp('http://[a-z]{0,3}\\.{0,1}youtube\\.com/watch\\?v=([0-9a-zA-Z-_]+)[\w&=]*', 'g'), '<a class="youtube" href="http://pl.youtube.com/watch?v=$1" target="_blank">[youtube]</a>'); | |
return msg; | |
} | |
function wiadomosc2(msg) { | |
msg = msg.replace(new RegExp('http://rdir\.pl\/([0-9a-zA-Z]+)', 'g'), '<a class="link" href="http://rdir.pl/$1" target="_blank">[link]</a>'); | |
msg = msg.replace(new RegExp('http://blip\.pl\/s\/([0-9]+)', 'g'), '<a class="blipniecie" href="http://blip.pl/s/$1" target="_blank" >[blip]</a>'); | |
msg = msg.replace(new RegExp('http://blip\.pl\/dm\/([0-9]+)', 'g'), '<a class="blipniecie" href="http://blip.pl/dm/$1" target="_blank" >[blip-dm]</a>'); | |
msg = msg.replace(new RegExp('http://blip\.pl\/pm\/([0-9]+)', 'g'), '<a class="blipniecie" href="http://blip.pl/pm/$1" target="_blank" >[blip-pm]</a>'); | |
msg = msg.replace(new RegExp('#([0-9a-zA-Z-_ąĄćĆęĘłŁńŃóÓŚśżŻźŹ]+)', 'g'), '<a class="tag" href="http://blip.pl/tags/$1" target="_blank" >#$1</a>'); | |
msg = msg.replace(new RegExp('([0-9a-zA-Z_.-]+)@([0-9a-zA-Z-]+).([a-zA-Z]+)', 'g'), '<a class="email" href="mailto:$1@$2.$3">[email]</a>'); | |
msg = msg.replace(new RegExp('\\^([0-9a-zA-Z-_]+)', 'g'), '<a class="wzmianka" href="http://blip.pl/users/$1/dashboard" target="_blank">^$1</a>'); | |
msg = msg.replace(new RegExp('http://[a-z]{0,3}\\.{0,1}youtube\\.com/watch\\?v=([0-9a-zA-Z-_]+)[\w&=]*', 'g'), '<a class="youtube" href="http://pl.youtube.com/watch?v=$1" target="_blank">[youtube]</a>'); | |
return msg; | |
} | |
function ile_wyzeruj() { | |
window.ile = 0; | |
chrome.browserAction.setBadgeText({text: ""}); | |
} | |
start(); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment