0

I need some help here. I'm coding a chrome extension and got stuck. I could get everything working (options page, script injection and a bunch of other stuff) but every time I try to read a text file from my domain I just can't do it.

Tried synced xmlHttpRequest (can't be synced deprecated) Tried asynced xmlHttpRequest(Load ERR) Tried using fetch(Load ERR)

I added the url to my manifest in many ways and still getting errors. Can someone point me some simple code where in my content script I can load a text file from a remote server (like https://www.stackoverflow/something/users.txt) and have that text in a variable I could parse?

the idea is to check for the user email inside that file for security reasons (I know is not that secure :p ) just a MVP for my security system.

I'm a photographer and this will be used for getting the models to sign their model releases and see their pictures so it doesnt need to be high security. Inside that file I will only have a encrypted list of emails(that is already working just need to retrieve the file)

Sorry for the size of the text. Thx to the community in advance

{ "name" : "hotkeys", "version": "0.0.1", "manifest_version": 2, "description" : "blah blah blah",

"permissions": [
    "storage",
],


"browser_action":{
    "default_popup": "html/options.html",
    "default_icon": {
       "16": "monkeymagic16.png",
       "24": "monkeymagic24.png",
       "32": "monkeymagic32.png",
       "48":"monkeymagic48.png",
       "128":"monkeymagic48.png"
    }
},


"content_scripts" : [
    {
        "js" : [
          "js/injectVariables.js",
         "js/alexhotkeys.js",
          "html/options.js"
        ],
        "css" : [
            "includes/mm.css"
         ],               
        "matches" : ["https://something.com/*"]
    }

]

}

  • Have you tried fetching the file in your background script? What specific errors are you encountering? – Abrar Hossain Jan 08 '21 at 17:41
  • what you mean background script? I have a script that keep listening for hotkeys document.addEventListener('keydown', function(e) { and I tried on that one... I used fetch and xmlHttpRequest added my manifest for reference. I'm doing it on alexhotkeys.js that is the main content script – Alexandre Leitão Jan 08 '21 at 17:54

0 Answers0