if (typeof chrome !== "undefined"){
    browser = chrome
}

var parts = window.name.split("#")
var color = parts[0]
var url = decodeURI(parts[1])

$(".button")
    .fadeIn()
    .click(function(){
        // todo: replace this scary alert with a message up to the
        // unpaywall.js content script, which can then pop up
        // a prettier and mre useful dialog box.
        if (color == "black") {
            alert("The Unpaywall extension " +
            "couldn't find any legal open-access version of this article.");
        }
        else {
            // send a message to the extension, so it can open this url
            // in a new tab
            browser.runtime.sendMessage({"upUrl": url});
        }
    })

$(".button").addClass(color)

@@ -138,11 +138,27 @@
 arts
-%5B1%5D
+.slice(1).join('#')
 )%0A%0A$

fix handling of urls with anchors