Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8383543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:11:19+00:00 2026-06-09T17:11:19+00:00

So I have a chrome extension that checks for an update of programs via

  • 0

So I have a chrome extension that checks for an update of programs via an xml document. However i get this error when I open a new tab:

Error in event handler for 'tabs.onActivated': Cannot call method 'getElementsByTagName' of null TypeError: Cannot call method 'getElementsByTagName' of null
at isUpdateAvailable (chrome-extension://bdhjocmpiogdmlfpbpppiffcjbonbocg/background.js:16:17)
at chrome-extension://bdhjocmpiogdmlfpbpppiffcjbonbocg/background.js:84:5
at chrome.Event.dispatch (event_bindings:237:41)
at Object.chromeHidden.Event.dispatchJSON (event_bindings:151:5

Code:

function loadXMLDoc(dname) {
    if (window.XMLHttpRequest) {    
        xhttp=new XMLHttpRequest();
    } else {
        xhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhttp.open("GET",dname,false);
    xhttp.send();
    return xhttp;
}

function isUpdateAvailable(type, build) {
    var buildNumber = localStorage["version" + build + type];
    var xml = loadXMLDoc("http://dl.bukkit.org/api/1.0/downloads/projects/" + build + "/view/latest-" + type + "/");
    var xmlDoc = xml.responseXML;
    var x = xmlDoc.getElementsByTagName("title")[0];
    var y = x.childNodes[0];
    var txt = y.nodeValue;
    if(txt == buildNumber) {
        return true;
    }
    xml.close();
    return false;
}

function notify(type, build) {
    window.webkitNotifications.createNotification('icon.png', getTitle(type, build), getDescription(type, build));
}

function getTitle(type, build) {
    var title;
    var xml = loadXMLDoc("http://dl.bukkit.org/api/1.0/downloads/projects/" + type + "/view/latest-" + build + "/");
    var xmlDoc=xml.responseXML;
    var name=xmlDoc.getElementsByTagName("name")[0];
    var version=xmlDoc.getElementsByTagName("version")[0];
    title+=name;
    title+=" version ";
    title+=version;
    title+=" is out!";
    xml.close();
    return title;
}

function getDescription(type, build) {
    var desc;
    var xml = loadXMLDoc("http://dl.bukkit.org/api/1.0/downloads/projects/" + type + "/view/latest-" + build + "/");
    var xmlDoc=xml.responseXML;
    var name=xmlDoc.getElementsByTagName("name")[0];
    desc+="There is a new update for ";
    desc+=name;
    desc+=". You can download it here: ";
    var downloadLink;
    get_short_url(long_url, function(short_url) {downloadLink=short_url;});
    desc+=downloadLink;
    xml.close();
    return desc;
}

function get_short_url(long_url, func) {
    var login = "kezz101";
    var api_key = "R_d68d87d13b42412a56be9bd9711c4dc4";
    $.getJSON("http://api.bitly.com/v3/shorten?callback=?", 
        { 
            "format": "json",
            "apiKey": api_key,
            "login": login,
            "longUrl": long_url
        },
        function(response) {
            func(response.data.url);
        }
    );
}

chrome.tabs.onActivated.addListener(function() {
    var type = localStorage["type"];
    var build = localStorage["build"];
    if(!type) {
        type = "rb";
    }
    if(!build) {
        build = "craftbukkit";
    }
    if(isUpdateAvailable(type, build)) {
        notify(type, build);
        var xml = loadXMLDoc("http://dl.bukkit.org/api/1.0/downloads/projects/" + type + "/view/latest-" + build + "/");
        var xmlDoc=xml.responseXML;
        localStorage["version" + build + type] = xmlDoc.getElementsByTagName("build_number")[0];
        xml.close();
    }
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:11:20+00:00Added an answer on June 9, 2026 at 5:11 pm

    You are using synchronous Ajax, which has been disabled for extensions and apps. You should instead use asynchronous Ajax with a callback passed into loadXMLDoc:

    function loadXMLDoc(dname, callback) {
        if (window.XMLHttpRequest) {    
            xhttp=new XMLHttpRequest();
        } else {
            xhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xhttp.open("GET",dname);
    
        xhttp.onload = function() {
            callback(xhttp);
        }
    
        xhttp.send();
    }
    
    function isUpdateAvailable(type, build, callback) {
        var buildNumber = localStorage["version" + build + type];
        loadXMLDoc("http://dl.bukkit.org/api/1.0/downloads/projects/" + build + "/view/latest-" + type + "/", function(xml) {
            var xmlDoc = xml.responseXML;
            var x = xmlDoc.getElementsByTagName("title")[0];
            var y = x.childNodes[0];
            var txt = y.nodeValue;
            if(txt == buildNumber) {
                callback(true);
            } else {
                xml.close();
                callback(false);
            }
        });
    }
    
    ...
    
    chrome.tabs.onActivated.addListener(function() {
        var type = localStorage["type"];
        var build = localStorage["build"];
        if(!type) {
            type = "rb";
        }
        if(!build) {
            build = "craftbukkit";
        }
        isUpdateAvailable(type, build, function(isAvail) {
            if(isAvail) {
                notify(type, build);
                var xml = loadXMLDoc("http://dl.bukkit.org/api/1.0/downloads/projects/" + type + "/view/latest-" + build + "/", function(xml) {
                    var xmlDoc=xml.responseXML;
                    localStorage["version" + build + type] = xmlDoc.getElementsByTagName("build_number")[0];
                    xml.close();
                });
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Chrome extension that modifies the header of requests before sending them.
I have this chrome extension that shows some content in the popup.html. As the
I have a chrome extension which have a server-side javascript and I need this
I have a Chrome Extension that is using the experimental sidebar API. It works
I want to have a chrome extension that adds a little bar to the
I have created a Chrome extension that uses the hotkeys [Alt]+[0...9] only to discover
I have a chrome extension that uses the facebook Graph API Because its a
I have a Google Chrome extension that upon pressing a button executes an xmlhttp
Suppose we have Chrome extension, that uses background page, popup page, maybe some other
I have chrome extension in that I am trying to use GWT RPC. Cant

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.