GithubHelp home page GithubHelp logo

icui / monkey-patch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iocave/monkey-patch

0.0 1.0 0.0 66 KB

Inject custom javascript into vscode

License: MIT License

JavaScript 2.38% TypeScript 97.62%

monkey-patch's Introduction

Monkey Patch README

What does it do

Monkey Patch is an extension allowing execution of arbitrary javascript in VSCode browser and main process

It can be either used directly using configuration options, or by other extensions using API.

Monkey Patch aims to make the entire process reliable (as far as monkey-patching goes...) and user friendly, by automatically checking the patching state after update, and prompting the user to repatch. It can also request elevated privileges if necessary.

Enabling and Disabling

Monkey Patch contributes two VSCode commands:

  • Enable Monkey Patch
  • Disable Monkey Patch

Using Monkey Patch through configuration options

While not the primary purpose, it is possible to use the Monkey Patch extension through options. For example:

"monkeyPatch.folderMap": {
    "my-custom-modules" : "~/custom-modules",
},
"monkeyPatch.browserModules": [
    // Will load "~/custom-modules/browser1.js" in browser process
    "my-custom-modules/browser1"
],
"monkeyPatch.mainProcessModules" : [
    // Will load "~/custom-modules/mainProcess.js" in main process
    "my-custom-modules/mainProcess1"
]

Using Monkey Patch through the API

let monkeyPatch = vscode.extensions.getExtension("iocave.monkey-patch");

if (monkeyPatch !== undefined) {
    monkeyPatch.exports.contribute("<publisher>.<extension_name>",
        {
            folderMap: {
                "my-custom-modules": path.join(this.context.extensionPath, "custom-modules"),
            },
            browserModules: [
                "my-custom-modules/browser1"
            ],
            mainProcessModules: [
                "my-custom-modules/mainProcess1",
            ]
        }
    );
} else {
    vscode.window.showWarningMessage("Monkey Patch extension is not installed. This extension will not work.");
}

For a full project that uses this, see https://github.com/iocave/customize-ui.

If something goes wrong

Monkey Patching can get fragile at times. If VSCode is running, you can unpach VSCode by invoking the "Disable Monkey Patch" command. If VSCode does launch, you can always redownload VSCode and replace the patched instance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.