New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow installing local files #2612
Comments
Perhaps this (match pattern docs)? Using |
That or the |
Adding a match pattern to detect |
I've been looking into this a bit. And I've come to two conclusions. The issue may have to do with disallowing filesystem access to WebExtensions, even if readonly through XHR (no source on this directly; edit: here at the very bottom). Or it could be related to same origin policy.
It might be worth bringing up in a bug report to allow filesystem access to paths defined in the manifest with the |
Yeah, it's probably the "no files" rule. Don't know where to get official guidance on that but I know it's true now that I think about it. You only get very special exceptions like the downloads API for making new files. We could try to figure a workaround like directly handling the drag/drop, or (LOL) reading the content of the tab that's already open. But then we'd fail to fetch relative icon/resource/requires, so it still won't go, without even more workarounds. |
Could you not use storage.local to cache the content using the url as a key before navigating the to install page? You already have the content in a variable. Of course the cache would have to be cleared once installed / decidedly not installed. Would be more convenient if WebExtensions had some sort of temporary storage so they don't have to manually deal with eviction. |
I've been messing around with what I've said and it's not as straightforward as I would have thought. Firstly, any user script has access to And of course, unless I'm mistaken, background scripts don't receive any references to the DOM / content in any of the navigation listeners? |
Turns out you can get the page content using Unfortunately it doesn't solve the file issue that was discussed. Some bugzilla tickets on it: |
I was directed here from #2671 If this thread is about importing from local file .... then ... If this thread is about recognising |
Ah, this could work. It's not as graceful as navigating to a
And it's much safer than the methods I was trying to use when attempting to keep the navigation workflow. |
Found a working webextension example using "input type="file"". Seems there's no need to cache, can be directly imported: |
It's not that the cache is needed, but rather a safety measure. Just like when you navigate to a .user.js the dialog pops up telling you some information about the script. I think the same should happen when you do the import. Therefore you need to store, somewhere not in the normal database, the script contents so that should the user click the install button you still have it available and don't need to prompt the user again. Whether this is cached using a storage API or just in a global object somewhere doesn't particularly matter for the workflow. |
I'd also like to say that an import feature should become top priority[1] as it would help with people having migration issues. They can just import the files from 3.x. [1] I'd look into it if @arantius has some ideas for how the process should work. |
I have import./Export in a number of my addons if examples are needed. The import is user initiated so there is no need for extra precautions/popups/notifications/warnings. Add an import button (file input) to one of the dialogues That is all.... I do the same in Import/Export preferences, Theme data (up to 500kb) and many others in my add-ons with Import/Export function.
Indeed .... that enables script writers to write new scripts and import to run or test and in case of the GM3 -> 4 upgrade, add the missed out scripts. The code and function is very simple... few lines of code which can be done in an hours. |
I'm not sure about this though. I don't particularly like skipping over the standard install dialog. Perhaps @arantius can give some insight on what he'd like to see in the addon. |
Standard dialogue is used when user is confronted with a user script from a remote source. A confirmation dialogue is then needed. In case of user initiated Import:
|
But this is not the way it goes... Installation is by callback (trigger on *.user.js)... |
Currently, yes. But it is possible to add an import button for local files. And not do installation on navigation for |
Ah, okay, for local files, that is quite appropriate. Not for remote files! ;-) |
As mentioned, we are talking about manual Import using file input |
Yes, I got it. That's okay for me for local files (see above)... |
I think it's possible to just drag&drop the .user.js on to Greasemonkey window to load the code of the script in to it? |
Is there a way (even a clumsy, non-drag-and-drop one) which allow me to import local GM scripts? In exactly which "cache" directory should the scripts be finally placed? I found several "cache" files in Firefox profile |
It is possible, like any other drop box (check my IMGoolge for an example). However, the straight forward file input would be the easiest method without the need for additional listeners and processes. |
Mozilla updated the doc (summary of the examples above):
With this implemented, we would have the same behavior as in GM3. |
So, any possible suggestions for manually installing a script that isn't offered in an appropriate online form? |
@Samizdata Currently the easiest way is to get GM beta (https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/versions/beta), open monkey menu --> new script. If you have scripts that @require local files, you can only do it the hard way. E.g. grab Proxomitron ( http://www.proxomitron.info/files/ ), run it, configure FF to use proxy 127.0.0.1:8080, place your files in the Proxomitron HTML folder and access them afterwards within FF with "http://bweb..local.ptron/YOURFILE.user.js". |
@kekkc, I think a new version with the remote resource problem fixed has been pushed to AMO. |
Cheers. That's done it, @kekkc ! |
|
@Eselce, yes. That should resolve the issues present when creating a new script with the 'new script' button and then applying a |
To have a
...which immediately starts serving all files in the directory where you run it, on (note that 8000 is the default port; you can change that; see below) That's how I put my local Python is installed by default in Linux and MacOs. If you would be using Windows and wouldn't have it installed and still plan on keep calling yourself a developer, then... seriously?! what's wrong with you? you have much more serious troubles than you can start to realize! I would suggest gardening 🌱 or knitting as hobbies rather than computers for you 😉 (hey, just kidding!) There is no need to install any strange programs -- you can, but that's absolutely unnecessary. Python is not an "app", it's a fundamental programming language. But you don't even need to "speak" Python for this solution, so don't quit or rush to your knitting tools just yet! Trivial procedure:
OR: for Phython 3.x, run
...where
Done. To close your local server, just go to the console where you run the python command and press Also, --and I hope this is ridiculously obvious to you--, please do not forget to run your Python HTTP server command line before expecting that Greasemonkey or Tampermonkey would be able to find the files... Tip: If you want to use a port other than the default
...and naturally update the |
Ok, Assume I click on the GM toolbar icon and select "New user script...." The new corresponding tab is auto-named "Unnamed Script 821696" Then I paste from a local file GM code into the tab pane and click the "save" icon on the upper left side. Where do I find later this script? Read: How can later edit this script? How can I change the name of the script to e.g. "foobar"? |
Ok, thank you. Just another question: On Nov 25th user kekkc told us in his posting (see above) that Mozilla offered a way to drag & drop files (from WinExplorer). So drag & drop of user files should be possible now. Am I right? When will it implemented in GM (available for drag & drop of *.user.js files)? |
FWIW I think we can/should detect navigation to |
We can detect navigation events but not get content (maybe in a content script) Although I find it silly to navigate to a |
Yes exactly, we're hamstrung. But we can detect intent and be as helpful as possible within our limited environment. |
My 2 cents ...
As mentioned by Sxderp, it is possible but a bit messy ...
Alternative ....
Personally, if it were me, I would opt for not adding extra listeners and simply have the IMPORT option added to the browserAction popup Additionally, I have not been using the |
This is what I meant. I might inject UI into the content page, though. We used to pop an infobar if you navigated to a script while GM was disabled; that sort of thing.
What does this mean? |
GM3 required the scripts to be named as In GM4, scripts are saved to IndexedDB and the script name doesn't really matter as it gets the name from The manual IMPORT, I would imagine wouldn't need be tied to |
Any progress on this? |
FireMonkey Extension can do this: |
In the past you could File>Open a
.user.js
and it would install. In 4.0 so far, it does nothing, just opens the file.The text was updated successfully, but these errors were encountered: