-
-
Save netsi1964/166127 to your computer and use it in GitHub Desktop.
This file contains 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
/* This is a template command. */ | |
CmdUtils.CreateCommand({ | |
names: ["links-on-page"], | |
icon: "http://www.netsi.dk/favicon.ico", | |
description: "Shows the no of links on current page", | |
help: "When you visit a page simple fire up <b>links-on-page</b> to see a count of links on current page.", | |
author: {name: "Sten Hougaard", email: "[email protected]"}, | |
license: "GPL", | |
homepage: "http://www.netsi.dk/ubiquity", | |
preview: function preview(pblock, args) { | |
try { | |
pblock.innerHTML = getInformation(); | |
} catch(e) { | |
pblock.innerHTML = e.message; | |
} | |
}, | |
execute: function execute(args) { | |
//displayMessage(getInformation(), this); | |
} | |
}); | |
var document = Application.activeWindow.activeTab.document; | |
var aLinks; | |
function getInformation() { | |
var sResult = ""; | |
try { | |
var aLinks = document.getElementsByTagName('a'); | |
sResult = "This page has " + aLinks.length.toString() + " links.<br />"; | |
sResult+='<ol>'; | |
for(var i=0; i<aLinks.length; i++) { | |
sResult+='<li>'+aLinks[i].innerHTML+'</li>'; | |
} | |
sResult+='</ol>'; | |
} catch(e) { | |
sResult = "Error in getInformation()"+e.message; | |
} | |
return sResult; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment