You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
5.3 KiB
140 lines
5.3 KiB
14 years ago
|
// ==UserScript==
|
||
|
// @name reverted PIM links
|
||
|
// @namespace Utopiah
|
||
|
// @description overlay so that a visited page indexed in a PIM displays a link back
|
||
|
// @include *
|
||
|
// @exclude *://mail.google.com/mail/*
|
||
|
// ==/UserScript==
|
||
|
|
||
|
/*
|
||
14 years ago
|
* Script homepage : http://fabien.benetou.fr/Tools/Greasemonkey#RevertedPIMLinks
|
||
14 years ago
|
*
|
||
14 years ago
|
* todo
|
||
|
* generate the data store on demand
|
||
|
* check link_extractor/revertingpimlinks.sh
|
||
|
*
|
||
14 years ago
|
* add links to the database
|
||
14 years ago
|
* note that date is optional but the source is not
|
||
|
* delicious-20100730.htm
|
||
|
* emails
|
||
|
* apply to Person/ cf earlier idea Seedea:Oimp/Socialannotating
|
||
|
* IRC/IM
|
||
14 years ago
|
34269 links using
|
||
|
for SCANNETWORK in $(ls ~/irclogs/); do grep http ~/irclogs/$SCANNETWORK/* | sed "s/.* <\(.*\)> .*http\(.*\)/http\2 \1 on $SCANNETWORK/"; done | wc -l
|
||
|
|
||
|
19881 freenode
|
||
|
5834 blinkenshell
|
||
|
4867 testing
|
||
|
2354 seedeabitlbee
|
||
|
1325 mozilla
|
||
|
7 rezosup
|
||
|
for SCANNETWORK in $(ls ~/irclogs/); do echo -n -e "$SCANNETWORK\t" && grep http ~/irclogs/$SCANNETWORK/* | sed "s/.* <\(.*\)> .*http\(.*\)/http\2 \1 on $SCANNETWORK/" | wc -l; done | awk '{print $2 "\t" $1}' | sort -n -r
|
||
|
|
||
|
*
|
||
|
*/
|
||
|
|
||
14 years ago
|
String.prototype.ColorHash = function(){
|
||
14 years ago
|
// from http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
|
||
14 years ago
|
var hash = 0;
|
||
|
if (this.length == 0) return hash;
|
||
|
for (i = 0; i < this.length; i++) {
|
||
|
char = this.charCodeAt(i);
|
||
|
hash = ((hash<<5)-hash)+char;
|
||
|
hash = hash & hash; // Convert to 32bit integer
|
||
|
}
|
||
|
hash = Math.round(Math.sqrt(Math.abs(hash))); // How to convert to 16bit integer?
|
||
|
return hash;
|
||
|
// suppose to send back a correct HTML color value
|
||
|
}
|
||
14 years ago
|
|
||
|
// configuration
|
||
|
var script_name = "rPIMlinks";
|
||
|
var PIM_URL = "http://fabien.benetou.fr/";
|
||
|
|
||
|
// actual script
|
||
|
|
||
|
//load URLs in data store (greasemonkey.scriptvals in about:config in prefs.js)
|
||
|
// load the entire set of links
|
||
|
// merging linksloaded_prefs.js to prefs.js
|
||
|
// C:\Documents and Settings\tyflser\Application Data\Mozilla\Firefox\Profiles\aosia15p.default
|
||
|
// e.g. user_pref("greasemonkey.scriptvals.Utopiah/reverted PIM links.rPIMlinks http://www.wikipedia.com/wiki/Simulacra_and_Simulation", "ReadingNotes/LeSpectateurEmancipe");
|
||
|
|
||
|
//everytime a page is loaded
|
||
|
|
||
|
//get the current URL
|
||
|
PIMpages = GM_getValue(script_name+" "+document.URL,"fail");
|
||
|
|
||
14 years ago
|
PIMpages_date = GM_getValue(script_name+" date","fail");
|
||
|
|
||
14 years ago
|
//if the current URL is in data store
|
||
|
if (PIMpages != "fail")
|
||
|
{
|
||
|
//display link
|
||
|
var pages = PIMpages.split(" ");
|
||
|
var myDiv = document.createElement('div');
|
||
14 years ago
|
myDiv.id = "GM_PIM_Window";
|
||
14 years ago
|
while (page = pages.shift()){
|
||
14 years ago
|
grouppage = page.split(".");
|
||
|
group = grouppage[0];
|
||
|
page = grouppage[1];
|
||
14 years ago
|
myDiv.innerHTML += "<p class=\"GM_PIM_link\">"
|
||
14 years ago
|
+"<a href=\""+PIM_URL+group+"/"+page+"\">"
|
||
|
+"<font color=\""+group.ColorHash()+"\">"+group+"</font>/"
|
||
|
+"<font color=\"white\">"+page+"</font>/"
|
||
|
+"</a>"
|
||
14 years ago
|
+"<sup><a href=\""+PIM_URL+page+"?action=edit\">[e]</a></sup>"
|
||
|
+"</p>";
|
||
|
}
|
||
14 years ago
|
boxcss = 'position:fixed; right:5px; top:5px; background-color:black; z-index:1; opacity:0.7;';
|
||
14 years ago
|
boxcss += 'padding:2px; margin:1px;';
|
||
|
boxcss += 'color:blue; font-size:10px; text-align:right;';
|
||
|
boxcss += 'border-width:3px; border-color:gray; border-style:solid;';
|
||
|
myDiv.style.cssText = boxcss;
|
||
14 years ago
|
myDiv.style.cssText += ' line-height:1px;';
|
||
|
myDiv.innerHTML += "<hr/><p style='font-size:8px; line-height:10px;' class='GM_PIM_ref'><a href='http://fabien.benetou.fr/Tools/Greasemonkey#RevertedPIMLinks'>RevertedPIMLinks</a></p>";
|
||
|
myDiv.innerHTML += "<p style='float:left;line-height:10px;' class='GM_PIM_ref' onclick=\"document.getElementById('GM_PIM_Window').style.visibility='hidden';document.getElementById('GM_PIM_Folded_Window').style.visibility='visible';\">>></p><br/>";
|
||
14 years ago
|
if (PIMpages_date != "fail")
|
||
|
{
|
||
|
myDiv.innerHTML += "<p> (date:"+PIMpages_date+")</p>";
|
||
14 years ago
|
}
|
||
|
document.body.appendChild(myDiv);
|
||
14 years ago
|
|
||
|
var myFoldedDiv = document.createElement('div');
|
||
|
myFoldedDiv.id = "GM_PIM_Folded_Window";
|
||
14 years ago
|
myFoldedDiv.innerHTML += "<p style='float:left;' class='GM_PIM_ref' onclick=\"document.getElementById('GM_PIM_Window').style.visibility='visible';document.getElementById('GM_PIM_Folded_Window').style.visibility='hidden';\"><<</p>";
|
||
|
myFoldedDiv.style.cssText = boxcss;
|
||
|
myFoldedDiv.style.cssText += "visibility:hidden;";
|
||
14 years ago
|
myFoldedDiv.style.cssText += "line-height:10px;";
|
||
14 years ago
|
document.body.appendChild(myFoldedDiv);
|
||
|
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
|
function shortcuts (e){
|
||
|
switch(e.charCode)
|
||
|
{
|
||
|
case "u".charCodeAt(0) : document.getElementById('GM_PIM_Window').style.visibility='visible';document.getElementById('GM_PIM_Folded_Window').style.visibility='hidden'; break;
|
||
|
case "f".charCodeAt(0) : document.getElementById('GM_PIM_Window').style.visibility='hidden';document.getElementById('GM_PIM_Folded_Window').style.visibility='visible'; break;
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
function registerShortcuts() {
|
||
|
window.addEventListener("keypress", shortcuts, true);
|
||
|
};
|
||
|
|
||
|
function unregisterShortcuts() {
|
||
|
window.removeEventListener("keypress", shortcuts, true);
|
||
|
};
|
||
|
|
||
|
registerShortcuts();
|
||
|
|
||
|
function registerListener(node) {
|
||
|
node.addEventListener("mouseover", function() {
|
||
|
unregisterShortcuts();
|
||
|
scroll_pause(); }, true);
|
||
|
node.addEventListener("mouseout", function() {
|
||
|
scroll_start ();
|
||
|
registerShortcuts();
|
||
|
}, true);
|
||
|
}
|