-
Notifications
You must be signed in to change notification settings - Fork 442
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
[Feature] Add integration to https://vscode.dev #1994
Comments
Jan Biniok (derjanb) is the developer of both Tampermonkey and Tampermonkey Editors. He has full control of the whole stuffs.
The two extensions communicate with each other. I tried to find out how it works, but Tampermonkey is closed source... |
Yeah, I thought about it myself, but I lack motivation because I use a local IDE + tracking.
FWIW, it's not obfuscated, so you can debug it in devtools, but it shouldn't be really necessary because the idea itself is clear and straightforward: open the site, find its internal API or editor instance in the MAIN world and use it directly. |
I am interesting in it coz I want to use better syntax highlighting and refractor features provided by Monaco Editor. I am now studying the required APIs to make the communications. |
WebCoder for ExtensionsI have drafted the extension. I think it might not be good to put it inside VM. Just like TM to keep it as a separate extension. (To be published in Chrome Store later; take it as a reference for your coding in VM first) As it use There are some APIs to be provided by VM via background page's options
list
get
patch
TM use the following urls for the communication. You can use different syntax as these are just for the file addressing. [
{
"name": "script.user.js",
"unders": [
"Violentmonkey Scripts",
"New Userscript 1"
],
"path": "ce6a2ec5-fb09-4de9-853a-e0a70c5da20e/source"
},
{
"name": "script.user.js",
"unders": [
"Violentmonkey Scripts",
"New Userscript 2"
],
"path": "dc50ca86-42fc-4df8-949c-90f7e68acee0/source"
},
{
"name": "script.user.js",
"unders": [
"https://gitstore.com/iFelix18",
"Greasy Fork++"
],
"path": "0d334a55-7003-4d2e-8625-8ea95c6df28c/source"
},
{
"name": "storage.json",
"unders": [
"https://gitstore.com/iFelix18",
"Greasy Fork++"
],
"path": "0d334a55-7003-4d2e-8625-8ea95c6df28c/storage"
},
{
"name": "https://fastly.jsdelivr.net/gh/sizzlemctwizzle/GM_config@06f2015c04db3aaab9717298394ca4f025802873/gm_config.min.js",
"unders": [
"https://gitstore.com/iFelix18",
"Greasy Fork++",
"external"
],
"path": "0d334a55-7003-4d2e-8625-8ea95c6df28c/external/https%3A%2F%2Ffastly.jsdelivr.net%2Fgh%2Fsizzlemctwizzle%2FGM_config%4006f2015c04db3aaab9717298394ca4f025802873%2Fgm_config.min.js"
},
{
"name": "https://fastly.jsdelivr.net/npm/@violentmonkey/shortcut@1.4.1/dist/index.min.js",
"unders": [
"https://gitstore.com/iFelix18",
"Greasy Fork++",
"external"
],
"path": "0d334a55-7003-4d2e-8625-8ea95c6df28c/external/https%3A%2F%2Ffastly.jsdelivr.net%2Fnpm%2F%40violentmonkey%2Fshortcut%401.4.1%2Fdist%2Findex.min.js"
},
{
"name": "https://fastly.jsdelivr.net/gh/roger810/userscript-supports@3fa07109efca28a21094488431363862ccd52d7c/library/WinComm.min.js",
"unders": [
"https://gitstore.com/iFelix18",
"Greasy Fork++",
"external"
],
"path": "0d334a55-7003-4d2e-8625-8ea95c6df28c/external/https%3A%2F%2Ffastly.jsdelivr.net%2Fgh%2Froger810%2Fuserscript-supports%403fa07109efca28a21094488431363862ccd52d7c%2Flibrary%2FWinComm.min.js"
}
] The actual directory shown in the editor is the "unders". So the users will see the file in the editor with your custom file directory and file name. For TM, Usage is just the same at this moment. Access TokenI made the concept of access token in this extension. You can totally ignore it if you don't need it. You can check the mock response (incoming & outgoing) in mock extension's background page. ![]() |
I don't see any benefit in having a separate extension. |
It can edit files in Stylus and VM in a same coding editor. VM and Stylus can just focus on their own functionality. As you know the editor in VM is quite basic with some syntax highlighting only using CodeMirror 5. And there are formatting issues in Stylus for stylus-language coding. You can just add this communication features to the external extensions so that people can have a better coding environment easily. It is no harm to VM itself. All the file control is still under VM scope. Besides, the local filing tracking option loses the control of the filing. VM itself does not know the editing. For the auto-update scripts, there might be problems. (and it requires the Also, it gives the ability to edit the GM storage settings directly. Of course it can be read-only which is controlled by VM side. All I want is that we can have a tool to edit the userscript and userstyle with modern coding IDE environment. We do not need a local application to do it. |
I've quickly looked at your extension and I'm surprised there's so much code and overrides in the MAIN world. Why?
I don't understand. Local editing is for the userscript author and the author is in control of everything.
Only in ancient Chrome before 86. See 2.16 release notes.
I need it because anything web-based is inferior and unreliable compared to a local IDE. |
Assuming all that complexity is really needed, I guess a separate extension would make sense indeed but I don't think we should allow it to see the list of the installed scripts. Instead I'd prefer that Violentmonkey sends the message to the extension, which will then load the script in vscode. @gera2ld, please read the thread. It's close to your idea of an external editor app. |
Just like our previous discussion in "Auto-Update". If "Auto-Update" without "allow edit", the author can still be able to edit the file externally and then it will become a conflict in VM control.
This is just an option. The users think themselves. If they like to edit in browser, this is their choice. |
This is possible. The communication flow is like this. Open the web page -> detected by WebCoder -> search the available extensions installed -> create connections to them to ask for option If the ext. extension can feedback correctly against option, it means that the extension is willing to communicate with WebCoder. Then WebCoder will send the list action to VM. VM can have its own control to send back what to display. Then come to the read/write process. When the user click on the file, WebCoder will send get action to VM. VM can response it or not. It can send back with some error message. If it is ok, VM sends back the file content. When the user saves the file, WebCoder will send patch action to VM. VM can response it or not. It can send back with some error message. If it is ok, VM changes the file and send back the response for the modification timestamp. |
There will be a conflict regardless of how the file is edited, because locally editing a file auto-updatable from an external source is inherently nonsensical.
Well, I don't like the idea of having an external extension that we don't have control over to have full access to the contents of any script and see the list of all scripts. I want the workflow to be fully controlled by the user clicking the "edit" button/icon in Violentmonkey. |
I can understand the appeal of the alternative approach that you suggest, but I meant I'd like this workflow:
Anyway, let's wait for @gera2ld, maybe he'll have a different idea. |
@cyfung1031, are you serious about taking the code from my browser extension, publishing it under an Apache-2.0 license on Github, and wanting to upload it to the Chrome Store? When @gera2ld "ported" Violentmonkey to Chrome, he obviously used Tampermonkey as a blueprint and even adopted bugs from Tampermonkey's code base, which were later fixed. But "WebCoder for Extensions" is something completely different. You took the minified code, had it formatted by a prettifier, renamed a few classes, and added (in my opinion) useless code. Since I published Tampermonkey Editors over a year ago, DMCA takedowns of the repository and a Chrome extension shouldn't be a problem. Nevertheless, a suggestion for a compromise: You are welcome to continue using the code if you change the license to MIT and adopt the license file from my repo, where I will publish the code of Tampermonkey Editors. You may even want to fork this repo later, since it'll contain a clean TypeScript code base. Actually, I wanted to clean up the code a bit first, but I can do that later. This, for example and just in case you ever wondered, is code that was only needed in the Tampermonkey extension when the page uses |
My idea was: To create a web version of VSCode, with a built-in VSCode extension to communicate with Violentmonkey, working as a replacement of the built-in editor and part of the dashboard. There should be just a few filesystem-like APIs so it is not necessary to create a separate browser extension for it. The website should be whitelisted and under our control and better to be loaded within Violentmonkey (as an iframe?) to avoid being injected by other extensions. With the power of VSCode, we may even allow users to write TypeScript directly. However, I lost my interest after proving its feasibility because I use Vim and it's much better than an editor in a browser. Anyway here is the flow in my mind:
|
@derjanb Thank you so much for letting us to continue this stuff :)
I just keep the API syntax (option, list, get, patch) cause I think it will be great that the editor extension can also communicate to Tampermonkey as well. So people can just use one extension to edit all. Thanks for having your time here. Besides, could you please have a look on the Orion's discussion regarding Tampermonkey's compatibility? That's a great browser based on Webkit engine to try to work as Chrome / Firefox. We solved the issue with Violentmonkey but not Tampermonkey. (see https://orionfeedback.org/d/547/)
In short, VM would be just a folder root in the editor. People can open other local files or do other things as well. People can edit local files and VM files in a same window. Communication Modes
From WebCoder to VM
From VM to WebCoder
[Feature for not built-in in VM] Separate Window (App) <Not yet implemented, but concept proved>
[Feature for not built-in in VM] History Record <Not yet implemented, but concept proved>
Security Concern
I am not sure about it. I just want syntax and hints for JS scripts. This lets the public contribution. |
Motivation
Someone (3rd party, I think) has developed an extension for Chrome ("Tampermonkey Editors") that allows you to edit your Tampermonkey scripts in vscode.dev.
https://chromewebstore.google.com/detail/tampermonkey-editors/lieodnapokbjkkdkhdljlllmgkmdokcm
This is really cool because of how feature-rich vscode is as a JavaScript editor. I think it'd be awesome if Violentmonkey could build this functionality into the VM core browser extension -- or maybe someone from the VM community would be interested in creating a second extension for this purpose.
Proposed Solution
I don't know how the Tampermonkey Editors extension works, but it does load vscode.dev with the query param
?connectTo=tampermonkey
. I suppose it's possible that this extension detects the presence of that query param and injects some code into vscode.dev to create a vscode filesystem provider that exposes the datastore of userscripts.Use Cases
vscode is really a joy to use for programming JavaScript, and it'd be cool if VM could stay competitive with TM on this feature.
The text was updated successfully, but these errors were encountered: