Mod Creation/Enabling DevTools for the Steam and Epic Clients: Difference between revisions

From Melvor Idle
(added non-main branch instructions)
Line 59: Line 59:
</ul>
</ul>
</ol>
</ol>
___
 
===Alternate Variation===
===Alternate Variation===
The following variant results in a cleaner directory without potential file name clashes. Note that the above does not clash for Combat Simulator + SEMI at the moment.
The following variant results in a cleaner directory without potential file name clashes. Note that the above does not clash for Combat Simulator + SEMI at the moment.
Line 145: Line 145:
<li>Add the following code to the parameters of package.json</li>
<li>Add the following code to the parameters of package.json</li>
<pre>"inject_js_end": "pathToYourFile/yourFileName.js"</pre>
<pre>"inject_js_end": "pathToYourFile/yourFileName.js"</pre>
</ol>
=Add Dev/Non-Main Branch Extensions to Chrome=
===Simple Installation===
'''Disclaimer:''' this installation method will never automatically update.
<ol>
<li>Navigate to https://gitlab.com/aldousWatts/SEMI or whichever repo you want.</li>
<li>On the left hand of the header, you should see a dropdown containing the word main. Click the dropdown, then select dev.</li>
<li>You should see a button in the header with a download icon. Click download, then .zip.</li>
<li>After the download completes, put the folder wherever you like. Extract the zip.</li>
<li>Open the link chrome://extensions/, enable Developer Mode in the top right.</li>
<li>Click the button Load unpacked in the header.</li>
<li>Navigate to the top-level directory of the unpacked extension. For SEMI, this is the one that contains the manifest, README, etc. Afterwards, click Select Folder.</li>
<li>After the extension loads, click update.</li>
<li>If you have the Chrome extension from the web store, ensure that you remove it.</li>
<li>Refresh the game.</li>
</ol>
===Managing Dev/Non-Main Branch Extensions w/ git===
This installation method will automatically fetch updates to dev/non-main branches.
<ol>
<li>Open your terminal to the location you want the folder to go.</li>
<li>Type the command git clone [email protected]:aldousWatts/SEMI.git into your terminal.</li>
<li>After it finishes cloning into the folder, cd into the folder then run git fetch && git checkout <branchname>.</li>
<li>Open the link chrome://extensions/, enable Developer Mode in the top right.</li>
<li>Click the button Load unpacked in the header.</li>
<li>Navigate to the top-level directory of the unpacked extension. For SEMI, this is the one that contains the manifest, README, etc. Afterwards, click Select Folder.</li>
<li>After the extension loads, click update.</li>
<li>If you have the Chrome extension from the web store, ensure that you remove it.</li>
<li>Refresh the game.</li>
</ol>
</ol>


{{Menu}}
{{Menu}}
[[Category:Guides]]
[[Category:Guides]]

Revision as of 23:24, 14 June 2021

This page was last updated for (v0.20).

Disclaimer: It is highly recommended to BACKUP YOUR SAVE before running any scripts or extensions.

Disclaimer: Do not run code you can not understand or do not trust. Malicious code could be included in any script and extension.

Before You Begin

It's highly recommended before doing anything to

  1. back up your save by exporting or downloading the save file.
  2. read all instructions before following them.
  3. verify the code is not malicious.

Steam Console and Scripts

To use console commands, scripts, and extensions on Steam, follow the instructions in Setup and Loading Scripts. There is an alternate variation that may result in a cleaner Melvor Idle folder.

Setup

You only have to do this once.

  1. Download Melvor Idle on Steam, and find the installation directory. e.g. [...]/steamapps/common/Melvor Idle
  2. Download the 0.49.2 version of NW.js SDK. The version might change in the future, but you need the specific one listed.
  3. Download the scripts and extensions you want to use.
  4. Extract all zipped files.
  5. Place the contents of the nwjs-sdk* directory in the Melvor Idle installation directory.
  6. Place the icons, styles, and source (i.e. scripts or sources) directories of the extracted extensions in the Melvor Idle installation directory.

Loading Scripts

Loading scripts must be run every time the game is opened on Steam.

  1. Open the game and load a character.
  2. Open the dev tools console (F12).
  3. Set the context of the console to game.
    • The top left of the console has a dropdown: change it from top to game (steam.melvoridle.com). After doing this, you can use the console.
  4. Load the scripts and extensions you placed in the installation directory before.
    • You can load SEMI like this:
    • require('fs').readFile('scripts/SEMI.js', 'utf8', (err, data) => {eval(data);})
      $(document.head).append(`<link rel="stylesheet" href="${chrome.runtime.getURL('styles/semi.css')}">`)
    • You can load the Combat Simulator like this:
    • require('fs').readFile('sources/contentScript.js', 'utf8', (err, data) => {eval(data);})
      $(document.head).append(`<link rel="stylesheet" href="${chrome.runtime.getURL('styles/mainStyle.css')}">`)
    • You can load user scripts like this, by changing the file name:
    • require('fs').readFile('relativePathToMyReallyCoolScript.js', 'utf8', (err, data) => {eval(data);})

Alternate Variation

The following variant results in a cleaner directory without potential file name clashes. Note that the above does not clash for Combat Simulator + SEMI at the moment.

Additional Setup

Do all the normal steps 1-5 of the Setup section then follow the below instructions.

  1. Create a directory Extensions in the Melvor Idle installation directory.
  2. Make new directories for the extensions and scripts. e.g.
  3. Extensions/
      Greasy Fork/
        Melvor Completion Log Helper.js
        Melvor Idle - Timestamped Saves.js
      Melvor-ETA/
        time-remaining.js
      MICS-steam/
        icons/
        sources/
        styles/
      scripts/
        nameOfMyReallyCoolScript.js
      SEMI-steam/
        icons/
        scripts/
        styles/
    
  4. Place the icons, styles, and source (i.e. scripts or sources) directories of the extracted extensions in the respective created directories.

Alternate Variation Loading Scripts

If you followed the alternate variation setup steps, you will have to load scripts slightly differently.

  1. Open the game and load a character.
  2. Open the dev tools console (F12).
  3. Set the context of the console to game.
    • The top left of the console has a dropdown: change it from top to game (steam.melvoridle.com). After doing this, you can use the console.
  4. Load the scripts and extensions you placed in the installation directory before.
  5. [
        // own
        'Extensions/scripts/nameOfMyReallyCoolScript.js',
        'Extensions/Melvor-ETA/time-remaining.js',
    
        // extensions
        // other than the main script, extensions typically also require the insertion of a css file
        'Extensions/MICS-steam/sources/contentScript.js',
        //'Extensions/SEMI-steam/scripts/SEMI.js',
    
        // Greasy Fork user scripts
        'Extensions/Greasy Fork/Melvor Completion Log Helper.js',
        'Extensions/Greasy Fork/Melvor Idle - Timestamped Saves.js',
    ].forEach(pts => require('fs').readFile(pts, 'utf8', (err, data) => {eval(data);}));
    
    // Extension css
    [
        'Extensions/MICS-steam/styles/mainStyle.css',
        //'Extensions/SEMI-steam/styles/semi.css',
    ].forEach(cssFile => $(document.head).append(`<link rel="stylesheet" href="${chrome.runtime.getURL(cssFile)}">`));
    
  6. If you are using extensions, edit the main extension script so all source files and icons can be found.
    • e.g. edit the paths in contentScript.js for Combat Simulator and SEMI.js for SEMI
    • Combat Simulator:
       -icons/ -> Extensions/MICS-steam/icons/
       -sources/ -> Extensions/MICS-steam/sources/
      SEMI:
       -icons/ -> Extensions/SEMI-steam/icons/
       -scripts/ -> Extensions/SEMI-steam/scripts/
      

Auto-loading Scripts in Steam

  1. Create a .js file in the Melvor Idle directory.
  2. Set the contents of the .js file
    • The 15000 is just to give the game 15 seconds to get up and running, it doesn't seem to matter if it fires on the character screen or once you load a character.
    setTimeout(function(){ 
         /*insert all of the commands you would normally put in the console to load your scripts*/
    }, 15000);
  3. Add the following code to the parameters of package.json
  4. "inject_js_end": "pathToYourFile/yourFileName.js"

Add Dev/Non-Main Branch Extensions to Chrome

Simple Installation

Disclaimer: this installation method will never automatically update.

  1. Navigate to https://gitlab.com/aldousWatts/SEMI or whichever repo you want.
  2. On the left hand of the header, you should see a dropdown containing the word main. Click the dropdown, then select dev.
  3. You should see a button in the header with a download icon. Click download, then .zip.
  4. After the download completes, put the folder wherever you like. Extract the zip.
  5. Open the link chrome://extensions/, enable Developer Mode in the top right.
  6. Click the button Load unpacked in the header.
  7. Navigate to the top-level directory of the unpacked extension. For SEMI, this is the one that contains the manifest, README, etc. Afterwards, click Select Folder.
  8. After the extension loads, click update.
  9. If you have the Chrome extension from the web store, ensure that you remove it.
  10. Refresh the game.

Managing Dev/Non-Main Branch Extensions w/ git

This installation method will automatically fetch updates to dev/non-main branches.

  1. Open your terminal to the location you want the folder to go.
  2. Type the command git clone [email protected]:aldousWatts/SEMI.git into your terminal.
  3. After it finishes cloning into the folder, cd into the folder then run git fetch && git checkout <branchname>.
  4. Open the link chrome://extensions/, enable Developer Mode in the top right.
  5. Click the button Load unpacked in the header.
  6. Navigate to the top-level directory of the unpacked extension. For SEMI, this is the one that contains the manifest, README, etc. Afterwards, click Select Folder.
  7. After the extension loads, click update.
  8. If you have the Chrome extension from the web store, ensure that you remove it.
  9. Refresh the game.