0

I tried creating a manifest that leads to a popup.js file and put the following code in that file but the popup showed up as just a white square.

This is My JavaScript code

fill(0, 0, 0);
ellipse(200, 200, 375, 375);
fill(60, 0, 255);
triangle(200, 104, 280, 280, 120, 280);
fill(255, 255, 255);
var answer = floor(random(1, 20));

if (answer === 1) {
    text("As I see it,", 171, 200);
    text("yes", 189, 229); 
}
else if (answer === 2) {
    text("Ask again", 171, 200);
    text("later", 189, 229); 

...

else {
    text("You may", 175, 200);
    text("rely on it", 177, 229); 
}

This is my manifest (most likely needs some editing)

{
  "manifest_version": 2,
  "name": "8 ball popup",
  "version": "0.1",
  "content_scripts": [
    {
      "matches": [
        "<all_urls>"
      ],
      "js": ["content.js"]
    }
  ],
  "browser_action": {
    "default_popup": "popup.html",
    "default_title": "Your fortune will appear here."
  }
}
  • See: https://stackoverflow.com/questions/950087/how-do-i-include-a-javascript-file-in-another-javascript-file/950146#950146 – Michael Hobbs May 04 '20 at 21:57

1 Answers1

1

Posting your manifest would help.

However, I recommend you checking the browerAction docs.

Basically you also need to create an HTML page, and link your js file to it.

Alex Buznik
  • 686
  • 1
  • 6
  • 26
  • I tried following the code on the docs, but when I click on the extension, a small white square is showing up underneath the icon, and nothing else. – Gangsta Gaming May 05 '20 at 20:37
  • I could not reproduce though. The white square underneath the icon is probably something that `browserAction.setBadgeText` could generate. Since you did not post your complete js or HTML code it's hard to tell. Probably you have some event handler for `chrome.browserAction.onClicked` (in background.js? Is the manifest you posted a complete one?) @GangstaGaming – Alex Buznik May 06 '20 at 10:27