kylepaulsen / ResourceOverride

An extension to help you gain full control of any website by redirecting traffic, replacing, editing, or inserting new content.
MIT License
467 stars 117 forks source link

Added upload file feature #55

Open vuciv opened 2 years ago

vuciv commented 2 years ago

The URL -> File rule's "Edit File" button would be replaced by an Upload File button. Instead of writing text in the extension, you can just upload a file.

kylepaulsen commented 2 years ago

Oh I misunderstood what you meant in https://github.com/kylepaulsen/ResourceOverride/issues/54

I thought you meant like, have Resource Override retain read access to that file indefinitely so even if you edit that file via your favorite editor outside of chrome, the changes are automatically reflected inside RO. The API I thought might be involved would be this one: https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API

In any case, this is still a good idea. The only thing I would ask is, we should keep the "Edit File" button going to the text editor page. Then somewhere in there, we could have a "upload file" button which would replace all the text in the editor with the uploaded file.

vuciv commented 2 years ago

Hey, @kylepaulsen! Thanks for your quick responses on this.

Honestly, I did mean that in #54. I am a Firefox user, and noticed that the API you mentioned is not supported by Firefox.

I think you’re right that the edit button should still be there. I may just be lazy, but I’d also like to be able to upload a file straight from the main screen. I think over time it would save me a lot of clicks.

Would it be unreasonable to have both buttons?

kylepaulsen commented 2 years ago

Hmm maybe. I'll think about it.

Have you tried using an http server first and using URL -> URL rules? That does give you the ability to "load" files directly from your filesystem and replace many things at the same time (if you use the "*" replacers described in the help). For example:

http://website.com/js/*.js    ----URL to URL---->      `http://localhost:8080/*.js

I know getting an http server set up can be annoying, but if you can easily do it, then you already have the feature you want. This is a nice http server: https://github.com/http-party/http-server If you want to replace stuff on a https site, that can be annoying cause you need to get cert files set up as described here: https://github.com/http-party/http-server#tlsssl

If you already tried this and still wish you had a upload button or this doesnt fit your use case, disregard what I said above.

vuciv commented 2 years ago

I haven't tried serving up my own http server... I have been using this extension as a replacement for Fiddler, because I find that Fiddler begins to interfere with other applications, and is a bit overkill for my requirements.

Do you think there would be any issues with an http server? I am not too well versed on this...

Also, I think I will submit another PR where there is a 'URL -> File (Editor)' rule and a 'URL -> File (Upload)' rule. Seems like the best of both worlds. Thoughts?

kylepaulsen commented 2 years ago

I definitely think you should try out an http server. Since you know how to program, I think you would get it quickly. For me, I just have to open a terminal, navigate where I want to host files, and just type hs. That command comes from the https://github.com/http-party/http-server I linked. It's using node.js, so you may have to install that first if you haven't already. It makes it super easy to start up a server though.

The only complications you could run into is trying to serve https content. I could try to explain what to do if you run into that. I also have a fork of the http server I linked above that tries to do all the hard parts for you, but it's horribly outdated. Just in case you wanted to look tho: https://github.com/kylepaulsen/http-server (looks the same, but there's a different way to install).

Anyway, I'm hesitant to clutter up the main page with more UI. I still think the best place would be in the edit file area. If you're adamant about minimizing clicks, one thing that I'm not completely against might be a very tiny button next to the "Edit File" button. Maybe it just uses a small icon to represent uploading a file.

Technically this extension is supposed to be in "maintenance mode" where I'm accepting no new features. However, I find myself having to fix things in a dramatic way because of manifest version 3 being forced on chrome extensions. The codebase is basically being rewritten at the moment. I guess this is just a heads up, that things may change dramatically, and your changes probably wont merge easily (or I'll just have to rewrite the feature anyway).