0

I am a beginner, created a chrome extension(.crx) which is working fine on my machine. But when i install the same file in other machine's chrome, the javascript in content.js and popup.js files is not working fine.

popup.js: Sends message to content.js to get how many rows are in pending state. Content.js: Counts rows which are in pending state and sends response.

popup.js:

function GetNoOfLinksClicked(e) {  
     chrome.tabs.query({"status":"complete","windowId":chrome.windows.WINDOW_ID_CURRENT,"active":true}, function(tabs){ 
     chrome.tabs.sendMessage(
        tabs[0].id,
        {from: 'CheckRows', subject: 'NoOfRowsPending'},
        refreshNoRowsPending); 
    });
}


function refreshNoRowsPending(noOfPendingRows)  {
            document.getElementById('pendingRows').textContent = noOfPendingRows;
}

content.js:

chrome.runtime.onMessage.addListener(function (msg, sender, response) {
    if ((msg.from === 'CheckRows') && (msg.subject === 'NoOfRowsPending')) {
        var noOfPendingRows= 0;
        $(".row_self").each(function() {
                      var status = $(this).find("td").eq(4).text();
                      if(status == "Pending"){
                            noOfPendingRows++;
                        }
                });
        response(noOfPendingRows);
    }
}

.crx is working fine and displaying count if i run if on chrome on which i have developed it, but not getting the count when i run it on chrome of other machine. Could someone help me ?

ItsME
  • 1
  • Any errors in console? – Serg Chernata Jan 05 '17 at 16:57
  • What *exactly* is shown in the [various appropriate consoles for your extension](http://stackoverflow.com/a/38920982/3773011) when you load and execute your extension? – Makyen Jan 05 '17 at 17:01
  • Please [edit] the question to be on-topic: include a **complete** [mcve] that *duplicates the problem*. Including a *manifest.json*, some of the background/content/popup scripts/HTML. Questions seeking debugging help ("**why isn't this code working?**") must include: ►the desired behavior, ►a specific problem or error *and* ►the shortest code necessary to reproduce it **in the question itself**. Questions without a clear problem statement are not useful to other readers. See: "**How to create a [mcve]**", [What topics can I ask about here?](http://stackoverflow.com/help/on-topic), and [ask]. – Makyen Jan 05 '17 at 17:01
  • Are you loading your content script via a `content_scripts` entry in *manifest.json*? If so, are you testing immediately after installing/enabling the extension without first reloading the web page on which you are wanting this to work? – Makyen Jan 05 '17 at 17:11
  • 1
    When an extension is installed/enabled, Chrome does not load *manifest.json* `content_scripts` in already open tabs with matching URLs. It only does so upon page load/reload. There are multiple ways to resolve this. Generally, if your user interaction *begins* with the user clicking a `browserAction` button, then the content script should be injected with [`chrome.tabs.executeScript()`](https://developer.chrome.com/extensions/tabs#method-executeScript) instead of a *manifest.json* `content_script` entry. – Makyen Jan 05 '17 at 17:16

0 Answers0