-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelicioustagreferenceadder.user.js
113 lines (96 loc) · 4.05 KB
/
delicioustagreferenceadder.user.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// ==UserScript==
// @name Delicious Tag Reference/Adder
// @namespace http://the-lastword.blogspot.com/
// @description Displays tags from del.icio.us for easy reference and adding to posts. Displays tags sorted by Frequency and Alphabetically. Also alters the post editors font to Tahoma and makes it a little smaller! A little aesthetic improvement! :)
// @include http://*blogger.com/post-*
// ==/UserScript==
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
addGlobalStyle('#textarea { font-size: 8pt; font-family: "Tahoma"}');
addGlobalStyle('.categories { position:absolute; top: 25%; right:1%; border:1px solid whitesmoke; padding:10px; width:200px } .categories a{font-size:7pt;color:gray; text-decoration:none; cursor:pointer} .categories a:hover{color:steelblue} #switch{position:absolute;top:19%;color:red;right:4%}')
function getBlogId()
{
var id = /blogid=(\d+)/i.exec( location.search );
if( id ) return id[1];
}
para = getBlogId();
var delname = GM_getValue('delname'+para);
if(!delname) {delname = prompt('Delicious Username?'); GM_setValue('delname'+para, delname);};
var holy_grail = document.createElement('div');
holy_grail.id="holy_grail";
var div = document.createElement('div');
var div1 = document.createElement('div');
div1.setAttribute('class','categories');
div1.innerHTML="Loading...";
div1.setAttribute('style','display:none');
div1.id="alpha";
holy_grail.appendChild(div1);
div.setAttribute('class','categories');
div.setAttribute('style','display:block');
div.id="freq";
div.innerHTML="Loading...";
holy_grail.appendChild(div);
document.getElementById('body').appendChild(holy_grail);
function cat_freq(data){
var Delicious_freq = {};
Delicious_freq.tags = eval('('+data.responseText+')');
document.getElementById('freq').innerHTML="";
if(!document.getElementById('f-address')){
for(var i in Delicious_freq.tags){
document.getElementById('freq').innerHTML+="<a onclick=\"javascript:document.getElementById ('tags').value+='"+i+",';\">"+i+"<\/a> - ";
}
}
else{
for(var i in Delicious_freq.tags){
document.getElementById('freq').innerHTML+="<a onclick=\"javascript:document.getElementById ('f-address').value+='"+i+",';document.getElementById('tags').value+='"+i+",';\">"+i+"<\/a> - ";
}
}
}
function cat_alpha(data){
var Delicious_alpha = {};
Delicious_alpha.tags = eval('('+data.responseText+')');
document.getElementById('alpha').innerHTML="";
if(!document.getElementById('f-address')){
for(var i in Delicious_alpha.tags){
document.getElementById('alpha').innerHTML+="<a onclick=\"javascript:document.getElementById ('tags').value+='"+i+",';\">"+i+"<\/a> - ";
}
}
else{
for(var i in Delicious_alpha.tags){
document.getElementById('alpha').innerHTML+="<a onclick=\"javascript:document.getElementById ('f-address').value+='"+i+",';document.getElementById('tags').value+='"+i+",';\">"+i+"<\/a> - ";
}
}
}
GM_xmlhttpRequest({'method':'GET',
'url':'http://del.icio.us/feeds/json/tags/'+delname+'?sort=freq&raw',
'onload':cat_freq
});
GM_xmlhttpRequest({'method':'GET',
'url':'http://del.icio.us/feeds/json/tags/'+delname+'?sort=alpha&raw',
'onload':cat_alpha
});
function toggle(){
if(document.getElementById('freq').style.display=="none"){
document.getElementById('freq').style.display="block";
document.getElementById('alpha').style.display="none";
}
else{
document.getElementById('freq').style.display="none";
document.getElementById('alpha').style.display="block";
}
}
function switcher(){
var switch_link = document.createElement('a');
switch_link.id="switch";
switch_link.innerHTML="Switch Tags View";
document.getElementById('body').appendChild(switch_link);
}
switcher();
document.getElementById('switch').addEventListener('click',toggle,true);