-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 91c23e9
Showing
10 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
content yourls-shortener chrome/content/ | ||
content yourls-shortener chrome/content/ contentaccessible=yes | ||
overlay chrome://browser/content/browser.xul chrome://yourls-shortener/content/browser.xul | ||
locale yourls-shortener en-US locale/en-US/ | ||
skin yourls-shortener classic/1.0 skin/ | ||
style chrome://global/content/customizeToolbar.xul chrome://yourls-shortener/skin/skin.css |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0"?> | ||
<?xml-stylesheet href="chrome://yourls-shortener/skin/skin.css" type="text/css"?> | ||
<!DOCTYPE overlay SYSTEM "chrome://yourls-shortener/locale/translations.dtd"> | ||
<overlay id="sample" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> | ||
<script src="yourlsshortener.js" /> | ||
<popup id="contentAreaContextMenu"> | ||
<menuitem id="yourls-shortener-context" insertafter="context-bookmarkpage" label="&shorten;" tooltiptext="&shortenlong;" oncommand="YOURLSshortener.run(content.location.href);" /> | ||
</popup> | ||
<statusbar id="status-bar"> | ||
<statusbarpanel id="yourls-shortener-status-bar-icon" class="statusbarpanel-iconic" src="chrome://yourls-shortener/skin/favicon.gif" tooltiptext="&shortenlong;" onclick="YOURLSshortener.run(content.location.href);" /> | ||
</statusbar> | ||
<toolbarpalette id="BrowserToolbarPalette"> | ||
<toolbarbutton id="yourls-shortener-toolbar-button" label="&shorten;" tooltiptext="&shortener;" | ||
class="toolbarbutton-1 chromeclass-toolbar-additional" type="menu"> | ||
<menupopup> | ||
<menuitem label="&shorten;" tooltiptext="&shortenlong;" onclick="YOURLSshortener.run(content.location.href);" /> | ||
<menuitem label="&gohome;" onclick="YOURLSshortener.gohome();" /> | ||
</menupopup> | ||
</toolbarbutton> | ||
</toolbarpalette> | ||
</overlay> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0"?> | ||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> | ||
|
||
<prefwindow title="YOURLS shortener" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> | ||
<script src="yourlsshortener.js" /> | ||
<prefpane label="YOURLS shortener preferences"> | ||
<preferences> | ||
<preference id="yourls-shortener-api" name="extensions.yourls-shortener.api" type="string"/> | ||
<preference id="yourls-shortener-signature" name="extensions.yourls-shortener.signature" type="string"/> | ||
<preference id="yourls-shortener-usesignature" name="extensions.yourls-shortener.usesignature" type="bool"/> | ||
<preference id="yourls-shortener-askforkey" name="extensions.yourls-shortener.askforkey" type="bool"/> | ||
</preferences> | ||
|
||
<groupbox> | ||
<caption label="Settings"/> | ||
<grid> | ||
<columns> | ||
<column flex="1"/> | ||
<column/> | ||
</columns> | ||
<rows> | ||
<row> | ||
<label control="api" tooltiptext="URL to the API, e.g. http://shortener.yoursite/" value="API URL"/> | ||
<textbox id="api" preference="yourls-shortener-api"/> | ||
</row> | ||
<row> | ||
<label control="signature" tooltiptext="Your signature to authenticate, e.g. 1234567890" value="Signature"/> | ||
<textbox id="signature" preference="yourls-shortener-signature"/> | ||
</row> | ||
<row> | ||
<label control="askforkey" tooltiptext="Do you want to provide keywords?" value="Ask for a keyword?"/> | ||
<checkbox id="askforkey" preference="yourls-shortener-askforkey"/> | ||
</row> | ||
<row> | ||
<spacer/> | ||
<button id="test" tooltiptext="Test the config by shorten the URL http://binfalse.de" label="test configuration" onclick="YOURLSshortener.run('http://binfalse.de')"/> | ||
</row> | ||
</rows> | ||
</grid> | ||
</groupbox> | ||
|
||
</prefpane> | ||
|
||
</prefwindow> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
var YOURLSshortener = function () { | ||
var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); | ||
return { | ||
gohome : function () { | ||
var api = prefManager.getCharPref("extensions.yourls-shortener.api"); | ||
if (api.substr(-1) != '/') | ||
api += '/'; | ||
window.open(api + "admin/"); | ||
return; | ||
}, | ||
run : function (long) { | ||
if (!long) | ||
{ | ||
alert ("lost my URL!?"); | ||
return; | ||
} | ||
|
||
var error = null; | ||
var api = prefManager.getCharPref("extensions.yourls-shortener.api"); | ||
if (api.substr(-1) != '/') | ||
api += '/'; | ||
api += "yourls-api.php"; | ||
|
||
if (api && api != 'http://yoursite/') | ||
{ | ||
try | ||
{ | ||
var params = 'action=shorturl&format=simple&url=' + long + '&signature=' + prefManager.getCharPref("extensions.yourls-shortener.signature"); | ||
|
||
if (prefManager.getBoolPref("extensions.yourls-shortener.askforkey")) | ||
{ | ||
var sel = ""; | ||
try | ||
{ | ||
sel = content.getSelection() + ""; | ||
} | ||
catch (e) {} | ||
|
||
var key = prompt("Type your keyword here (leave empty to generate)", sel.toLowerCase ()); | ||
if (key) | ||
params += '&keyword=' + key; | ||
} | ||
|
||
var request = new XMLHttpRequest(); | ||
request.open("POST", api, false); | ||
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | ||
request.setRequestHeader("Content-length", params.length); | ||
request.setRequestHeader("Connection", "close"); | ||
request.send(params); | ||
if (request.status == 200 || request.status == 201) | ||
{ | ||
if () | ||
{ | ||
alert ('Your shorten URL:\n' + request.responseText); | ||
return; | ||
} | ||
else | ||
error = "Shorten failed.. Maybe invalid key!?" | ||
} | ||
else | ||
error = "API returned crap!"; | ||
} | ||
catch (e) | ||
{ | ||
error = "Failed to start XMLHttpRequest:\n" + e.message; | ||
} | ||
|
||
} | ||
else | ||
error = "No API-URL specified... Check your settings!"; | ||
|
||
if (error) | ||
alert (error); | ||
} | ||
}; | ||
}(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pref("extensions.yourls-shortener.api", "http://yoursite/"); | ||
pref("extensions.yourls-shortener.signature", "123456"); | ||
pref("extensions.yourls-shortener.askforkey", false); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?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>[email protected]</em:id> | ||
<em:name>YOURLS shortener</em:name> | ||
<em:version>1.0</em:version> | ||
<em:type>2</em:type> | ||
<em:creator>Martin Scharm</em:creator> | ||
<em:description>Shorten URLs with your own YOURLS instance</em:description> | ||
<em:homepageURL>http://binfalse.de/</em:homepageURL> | ||
<em:optionsURL>chrome://yourls-shortener/content/options.xul</em:optionsURL> | ||
<em:iconURL>chrome://yourls-shortener/skin/favicon.gif</em:iconURL> | ||
<em:targetApplication> | ||
<Description> | ||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> | ||
<em:minVersion>3.0</em:minVersion> | ||
<em:maxVersion>4.*</em:maxVersion> | ||
</Description> | ||
</em:targetApplication> | ||
</Description> | ||
</RDF> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!ENTITY shortener "YOURLS shortener"> | ||
<!ENTITY shorten "Shorten"> | ||
<!ENTITY shortenlong "Shorten this page with YOURLS"> | ||
<!ENTITY gohome "Browse to the API"> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#yourls-shortener-toolbar-button, #yourls-shortener-context { | ||
list-style-image: url("chrome://yourls-shortener/skin/favicon.gif"); | ||
} | ||
#yourls-shortener-status-bar-icon { | ||
margin: 0 2px; | ||
} |
Binary file not shown.