PluginBuilder


{info} Reach out to an extension administrator to be granted developer access and enable the PluginBuilder feature. Join our discord

{danger.fa-close} This feature is only supported on Chromium-based browsers.


Getting set up for local development

Begin by creating a new folder named after your feature. Inside that folder, create a file called deflypowerup.json.

The deflypowerup.json file acts as a configuration file that tells the extension where your code is located. Example:

{
  "name": "MyFeature",
  "version": "1.0.0",
  "manifest_version": 1,
  "type": "replacement",
  "replacements": [
    "expressions/myExpression.json"
  ],
  "scripts": [
    "scripts/index.js"
  ],
  "stylesheets": [
    "styles/main.css"
  ]
}

{info} Once your plugin is complete and ready for publication on the extension, create a post about it here.

Properties

Key Type Description
name str Name of the feature (no spaces)
version str Version of the feature
manifest_version int Version of the deflypowerup.json file
type enum "javascript" or "replacement" (replacement requires a reload when enabling and disabling, whereas javascript only needs a reload when disabled). If you have any replacements, use "replacement".
replacements array List of replacement files
scripts array List of script files
style array List of stylesheets

Testing

After you have a project folder with a manifest file, you can upload it to the extension for local development and testing. Start by going to defly.io and opening the settings menu. Search for PluginBuilder, click Configure, then Open a project. After selecting the folder, open it and the feature will request permission through the browser to access that folder.

Javascript files

{info} All script files are appended to each other in the order they are listed in deflypowerup.json.

After making changes to your scripts in an IDE, reload defly while the PluginBuilder is connected.

Replacement Files

{danger} If you make a severe enough change to the defly script, your client may fail to load the extension. In doing so, you lose the ability to disable those replacements. If this happens, contact the extension developer (an undo feature is in progress).

Replacement files use regular expressions to modify the defly script. There are multiple regex variants, in this case create them with goal of PHP compatibility.

Example from Alex's plugin MiniMapNames:

{
  "expression": "/;for\(var ([A-z]+) in ([A-z]+)\){if\(([^&]+)&&([^=]+)==([A-z]+)([^<]+)([^}]+)<\/div>'/ui",
  "replacement": ";window.teammates=$2;for(var $1 in $2){if($3&&$4==$5$6$7'+((window.loadPlayerToMinimap&&window.loadPlayerToMinimap($1))||'')+'</div>'"
}

This modifies the loop used by defly to render teammates on the minimap. It creates HTML with the player names via loadPlayerToMinimap then aligns them with their map dots using stylesheet rules.