Skip to content

Instantly share code, notes, and snippets.

@scturtle
Created December 12, 2014 12:50
Show Gist options
  • Save scturtle/17e1bd67509c8e37ef96 to your computer and use it in GitHub Desktop.
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
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