Created
December 12, 2014 12:50
-
-
Save scturtle/17e1bd67509c8e37ef96 to your computer and use it in GitHub Desktop.
firefox addon adding a button which shows whether the current url has been added into Delicious.com
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
var buttons = require('sdk/ui/button/action'); | |
var tabs = require("sdk/tabs"); | |
var prefs = require('sdk/simple-prefs'); | |
var Request = require("sdk/request").Request; | |
var button = buttons.ActionButton({ | |
id: "delicious-check", | |
label: "delicious-check", | |
icon: "./tagOff.png", | |
onClick: check | |
}); | |
function check(state) { | |
var username = prefs.prefs['username']; | |
var password = prefs.prefs['password']; | |
var querystring = 'http://' + username + ':' + password + '@api.del.icio.us/v1/posts/get?url=' + encodeURIComponent(tabs.activeTab.url); | |
var latestTweetRequest = Request({ | |
url: querystring, | |
onComplete: function (response) { | |
if(response.text.indexOf("no bookmarks") == -1) | |
button.state("tab", { icon: "./tagOn.png" }); | |
else | |
button.state("tab", { icon: "./tagOff.png" }); | |
} | |
}).get(); | |
} | |
tabs.on('ready', function(tab) { | |
check(null); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment