Code-Injector icon indicating copy to clipboard operation
Code-Injector copied to clipboard

Cannot load local file (Windows)

Open lubieowoce opened this issue 4 years ago • 4 comments

Hi, I can't seem to get a local file to load. (FF73, Windows 10). I entered a path like this in Add Rule/Files:

/C:/Users/me/Documents/path/to/script.js

This should work fine when the file:// prefix is added, as is done here: https://github.com/Lor-Saba/Code-Injector/blob/3ef819aa51a3ccfed882ef0526d8316ec0485d6c/script/main/background.js#L501 indeed, in a separate tab, file:///C:/Users/me/Documents/path/to/script.js opens without a hitch. However CodeInjector can't load it - i'm getting

Code-Injector [ERROR]: The browser can not load the file file://<above path>

in the console. The plugin debugger (about:debugging#/runtime/this-firefox) shows:

Security Error: Content at moz-extension://edcfd096-d164-486d-9e6a-a36ec6ea575e/_generated_background_page.html may not load or link to file://<above path>

Any idea how to solve this? I looked around in the plugin's options, but couldn't find anything related to file access permissions - the "Permissions" tab list only the following:

  • Access your data for all websites
  • Access browser tabs
  • Access browser activity during navigation

lubieowoce avatar Mar 10 '20 14:03 lubieowoce

Possibly related Firefox issue: Firefox 68: local files now treated as cross-origin (1558299)

Unfortunately, the proposed workaround of setting privacy.file_unique_origin = false doesn't change anything. Maybe changing this line

https://github.com/Lor-Saba/Code-Injector/blob/3ef819aa51a3ccfed882ef0526d8316ec0485d6c/script/main/background.js#L505

to use cross-origin would help?

lubieowoce avatar Mar 10 '20 17:03 lubieowoce

He lubieowoce ! Have you find a solution for this? I'm trying to inject an iframe from my local drive but it only loads files from https services.

rx65m avatar Oct 23 '20 08:10 rx65m

@rx65m not really :( i've resorted to running a local server that serves the files i need:

cd <directory with code>
python -m http.server 8000

and then injecting localhost:8000/myfile.js with CodeInjector. it's not ideal, but works well enough for development

lubieowoce avatar Oct 25 '20 09:10 lubieowoce

Unfortunately, the server thing doesn't work for me. I get this error "Code-Injector [JS] - Error loading: http://localhost:8000/test.js". But the page is normally accessible in the browser. Does anyone still have a solution?

Nitrama avatar May 22 '22 22:05 Nitrama