Permalink
Browse files

added example firefox extension to start modifying

  • Loading branch information...
1 parent c42c7ea commit 40a734aee992c24c4008ffd6c687214061afcc80 @FarMcKon committed Apr 3, 2011
View
@@ -0,0 +1,8 @@
+content linktargetfinder chrome/content/
+content linktargetfinder chrome/content/ contentaccessible=yes
+overlay chrome://browser/content/browser.xul chrome://linktargetfinder/content/browser.xul
+
+locale linktargetfinder en-US locale/en-US/
+
+skin linktargetfinder classic/1.0 skin/
+style chrome://global/content/customizeToolbar.xul chrome://linktargetfinder/skin/skin.css
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://linktargetfinder/skin/skin.css" type="text/css"?>
+<!DOCTYPE linktargetfinder SYSTEM "chrome://linktargetfinder/locale/translations.dtd">
+<overlay id="sample" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="linkTargetFinder.js" />
+
+ <menupopup id="menu_ToolsPopup">
+ <menuitem label="&runlinktargetfinder;" key="link-target-finder-run-key" oncommand="linkTargetFinder.run()"/>
+ </menupopup>
+
+ <keyset>
+ <key id="link-target-finder-run-key" modifiers="accel alt shift" key="L" oncommand="linkTargetFinder.run()"/>
+ </keyset>
+
+ <statusbar id="status-bar">
+ <statusbarpanel id="link-target-finder-status-bar-icon" class="statusbarpanel-iconic" src="chrome://linktargetfinder/skin/status-bar.png" tooltiptext="&runlinktargetfinder;" onclick="linkTargetFinder.run()" />
+ </statusbar>
+
+ <toolbarpalette id="BrowserToolbarPalette">
+ <toolbarbutton id="link-target-finder-toolbar-button" label="Link Target Finder" tooltiptext="&runlinktargetfinder;" oncommand="linkTargetFinder.run()"/>
+ </toolbarpalette>
+</overlay>
@@ -0,0 +1,44 @@
+var linkTargetFinder = function () {
+ var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
+ return {
+ init : function () {
+ gBrowser.addEventListener("load", function () {
+ var autoRun = prefManager.getBoolPref("extensions.linktargetfinder.autorun");
+ if (autoRun) {
+ linkTargetFinder.run();
+ }
+ }, false);
+ },
+
+ run : function () {
+ var head = content.document.getElementsByTagName("head")[0],
+ style = content.document.getElementById("link-target-finder-style"),
+ allLinks = content.document.getElementsByTagName("a"),
+ foundLinks = 0;
+
+ if (!style) {
+ style = content.document.createElement("link");
+ style.id = "link-target-finder-style";
+ style.type = "text/css";
+ style.rel = "stylesheet";
+ style.href = "chrome://linktargetfinder/skin/skin.css";
+ head.appendChild(style);
+ }
+
+ for (var i=0, il=allLinks.length; i<il; i++) {
+ elm = allLinks[i];
+ if (elm.getAttribute("target")) {
+ elm.className += ((elm.className.length > 0)? " " : "") + "link-target-finder-selected";
+ foundLinks++;
+ }
+ }
+ if (foundLinks === 0) {
+ alert("No links found with a target attribute");
+ }
+ else {
+ alert("Found " + foundLinks + " links with a target attribute");
+ }
+ }
+ };
+}();
+window.addEventListener("load", linkTargetFinder.init, false);
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<prefwindow
+ title="Link Target Finder Preferences"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <prefpane label="Link Target Finder Preferences">
+ <preferences>
+ <preference id="link-target-finder-autorun" name="extensions.linktargetfinder.autorun" type="bool"/>
+ </preferences>
+
+ <groupbox>
+ <caption label="Settings"/>
+ <grid>
+ <columns>
+ <column flex="4"/>
+ <column flex="1"/>
+ </columns>
+ <rows>
+ <row>
+ <label control="autorun" value="Autorun"/>
+ <checkbox id="autorun" preference="link-target-finder-autorun"/>
+ </row>
+ </rows>
+ </grid>
+ </groupbox>
+
+ </prefpane>
+
+</prefwindow>
@@ -0,0 +1 @@
+pref("extensions.linktargetfinder.autorun", false);
View
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+ <Description about="urn:mozilla:install-manifest">
+ <em:id>linktargetfinder@robertnyman.com</em:id>
+ <em:name>Link Target Finder</em:name>
+ <em:version>1.0</em:version>
+ <em:type>2</em:type>
+ <em:creator>Robert Nyman</em:creator>
+ <em:description>Finds links that have a target attribute</em:description>
+ <em:homepageURL>http://www.robertnyman.com/</em:homepageURL>
+ <em:optionsURL>chrome://linktargetfinder/content/options.xul</em:optionsURL>
+
+ <em:targetApplication>
+ <Description>
+ <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+ <em:minVersion>2.0</em:minVersion>
+ <em:maxVersion>3.1b2</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+ </Description>
+</RDF>
@@ -0,0 +1 @@
+<!ENTITY runlinktargetfinder "Run Link Target Finder">
View
@@ -0,0 +1,12 @@
+#link-target-finder-toolbar-button {
+ list-style-image: url("chrome://linktargetfinder/skin/toolbar-large.png");
+}
+
+#link-target-finder-status-bar-icon {
+ width: 83px;
+ margin: 0 5px;
+}
+
+.link-target-finder-selected {
+ outline: 2px solid red !important;
+}
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 40a734a

Please sign in to comment.