-
Notifications
You must be signed in to change notification settings - Fork 13
/
pop.js
50 lines (46 loc) · 1.81 KB
/
pop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//changed by [email protected]
var $=function(i){return document.getElementById(i)};
function replay(){
var url = this.dataset.url;
var cookie = this.dataset.cookie;
var ua = this.dataset.ua;
localStorage.setItem('ua',ua);
var data={};
var subdomain = (function(url){
var a = document.createElement('a');
a.href=url;
var link = a.hostname.split('.');
if(link.length>2)
return link.slice(1).join('.');
else
return a.hostname;
})(url);
cookie.split(';').forEach(function(o){var d=o.replace(/\s*/,'').split('=');data[d[0]]=d[1]});
for(var k in data){
chrome.cookies.set({url:url,name:k,value:data[k],domain:subdomain,path:'/'});
}
open(url);
}
function render(cookies){
var list = document.getElementById('list');
for(var i=0,x,html='';x=cookies[i];i++){
x.desc_url=x.url.length>75?x.url.substr(0,75):x.url;
html+="<li><a title=':{url}' data-url=\":{url}\" data-ua=\":{ua}\" href='javascript:;' data-cookie=\":{cookie}\">:{desc_url}</a></li>".replace(/:{\w+}/ig,function(k){return x[k.substring(2,k.length-1)]});
//html+="<li><a title=':{url}' href='javascript:void(0)' onclick=\"replay(this.dataset.url,this.dataset.cookie)\" data-url=\":{url}\" data-cookie=\":{cookie}\">:{desc_url}</a></li>".replace(/:{\w+}/ig,function(k){return x[k.substring(2,k.length-1)]});
}
list.innerHTML=html;
var btn = document.getElementsByTagName("a");
for(var i=0;i<btn.length;i++){
//list[i].addEventListener('click',replay(list[i].dataset.url,list[i].dataset.cookie));
btn[i].addEventListener('click',replay);
}
}
$('f').onsubmit=function(){
localStorage.clear();
localStorage.setItem('xsser',$('xsser').value);
if($('xsser').value){
chrome.extension.getViews()[0].load();
}
}
xsser.value=localStorage.getItem('xsser');
render(JSON.parse(localStorage.getItem('data')));