browser.js
function scriptPrefix(filename) {
    var scripts = document.querySelectorAll('script[src*="' + filename + '"]');
    if (scripts.length !== 1) {
        return null;
    }
    var script = scripts[0].src;
    return script.substring(0, script.indexOf(filename));
}
function scriptPrefix(filename) {
    var scripts = document.querySelectorAll('script[src*="' + filename + '"]');
    if (scripts.length !== 1) {
        return null;
    }
    var script = scripts[0].src;
    return script.substring(0, script.indexOf(filename));
}
Finds the directory that a loaded script is hosted on.

@param {string} filename
@return {string?}