forked from Ittai/ittai
1
0
Fork 0

Tutoritals

aa/multi-mod-support
Kyza 2021-01-27 13:17:43 -05:00
parent 73921078ca
commit 9cd3dee3ef
No known key found for this signature in database
GPG Key ID: 4CDDED9862F80924
37 changed files with 1643 additions and 18 deletions

View File

@ -2,7 +2,7 @@
* @module entities
*/
import { getClientMod } from "../utils";
import { getClientMod, patcher } from "../utils";
const faURL =
"https://kit-pro.fontawesome.com/releases/v5.15.1/css/pro.min.css";
@ -20,12 +20,20 @@ export const Plugin = (() => {
);
}
let pluginEntity;
switch (getClientMod()) {
case "powercordv2":
return require("./PCv2Plugin");
pluginEntity = require("./PCv2Plugin");
case "vizality":
return require("./VZPlugin");
pluginEntity = require("./VZPlugin");
case "betterdiscord":
return require("./BDPlugin");
pluginEntity = require("./BDPlugin");
}
// Unpatch all.
const oldStop = { ...pluginEntity }.stop;
pluginEntity.stop = () => {
oldStop();
patcher.unpatchAll();
};
})();

View File

@ -16,6 +16,7 @@ export let patches = [];
* @param {string} functionName The name of the function to patch.
* @param {function} patchFunction The code to patch into the function.
* @returns {object} {@link module:patcher.patch~patchData}
* @tutorial patchingBefore
*/
export function before(name, object, functionName, patchFunction) {
return patch(name, object, functionName, "before", patchFunction);
@ -27,6 +28,7 @@ export function before(name, object, functionName, patchFunction) {
* @param {string} functionName The name of the function to patch.
* @param {function} patchFunction The code to patch into the function.
* @returns {Object} {@link module:patcher.patch~patchData}
* @tutorial patchingInstead
*/
export function instead(name, object, functionName, patchFunction) {
return patch(name, object, functionName, "instead", patchFunction);
@ -38,6 +40,7 @@ export function instead(name, object, functionName, patchFunction) {
* @param {string} functionName The name of the function to patch.
* @param {function} patchFunction The code to patch into the function.
* @returns {object} {@link module:patcher.patch~patchData}
* @tutorial patchingAfter
*/
export function after(name, object, functionName, patchFunction) {
return patch(name, object, functionName, "after", patchFunction);
@ -62,6 +65,7 @@ export function unpatchAll(unpatches = patches) {
* @param {string} type The type of patch to apply. `before`, `instead`, `after`.
* @param {function} patchFunction The code to patch into the function.
* @returns {object} {@link module:utils/patcher.patch~patchData}
* @tutorial patching
*/
export function patch(name, object, functionName, type, patchFunction) {
if (!object.__ittai__) object.__ittai__ = {};

View File

@ -58,6 +58,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a

View File

@ -58,6 +58,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a

View File

@ -58,6 +58,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a
@ -106,7 +122,7 @@
* @module entities
*/
import { getClientMod } from "../utils";
import { getClientMod, patcher } from "../utils";
const faURL =
"https://kit-pro.fontawesome.com/releases/v5.15.1/css/pro.min.css";
@ -124,14 +140,22 @@ export const Plugin = (() => {
);
}
let pluginEntity;
switch (getClientMod()) {
case "powercordv2":
return require("./PCv2Plugin");
pluginEntity = require("./PCv2Plugin");
case "vizality":
return require("./VZPlugin");
pluginEntity = require("./VZPlugin");
case "betterdiscord":
return require("./BDPlugin");
pluginEntity = require("./BDPlugin");
}
// Unpatch all.
const oldStop = { ...pluginEntity }.stop;
pluginEntity.stop = () => {
oldStop();
patcher.unpatchAll();
};
})();
</code></pre>
</article>

View File

@ -56,6 +56,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a
@ -181,11 +197,11 @@
<ul>
<li><a href="https://git-scm.com/">Git</a></li>
<li><a href="https://nodejs.org/">NodeJS</a></li>
<li><a href="https://yarnpkg.com/">Yarn</a> (optional)</li>
<li><a href="https://pnpm.js.org/">pnpm</a> (optional)</li>
</ul>
<h3>Installation Steps</h3>
<pre class="prettyprint source lang-bash"><code>git clone https://github.com/Kyza/ittai/
yarn
pnpm i
</code></pre>
<h2>How to Build</h2>
<h3>Command Options</h3>
@ -217,7 +233,7 @@ yarn
</ul>
<h3>Build Command</h3>
<p>This command will build your plugin for BetterDiscord, Powercord v2, and Vizality, but will only copy it to the Vizality plugin's folder. It will also hot rebuild your plugin for you.</p>
<pre class="prettyprint source lang-bash"><code>yarn start --plugin=&quot;./test/plugin&quot; --betterdiscord --powercordv2 --vizality=&quot;C:/Users/Kyza/GitHub/vizality/addons/plugins/fgbd&quot; --watch
<pre class="prettyprint source lang-bash"><code>pnpm start --plugin=&quot;./test/plugin&quot; --betterdiscord --powercordv2 --vizality=&quot;C:/Users/Kyza/GitHub/vizality/addons/plugins/fgbd&quot; --watch
</code></pre></article>
</section>

View File

@ -58,6 +58,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a

View File

@ -56,6 +56,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a

View File

@ -56,6 +56,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a

View File

@ -56,6 +56,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a

View File

@ -56,6 +56,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a

View File

@ -56,6 +56,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a

View File

@ -56,6 +56,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a
@ -312,7 +328,7 @@
<p class="tag-source">
<a href="utils_patcher.js.html" class="button">View Source</a>
<span>
<a href="utils_patcher.js.html">utils/patcher.js</a>, <a href="utils_patcher.js.html#line75">line 75</a>
<a href="utils_patcher.js.html">utils/patcher.js</a>, <a href="utils_patcher.js.html#line79">line 79</a>
</span>
</p>
@ -591,6 +607,13 @@
<dt class="tag-tutorial">Tutorials:</dt>
<dd class="tag-tutorial">
<ul>
<li><a href="tutorial-patchingAfter.html">Patching After</a></li>
</ul>
</dd>
@ -601,7 +624,7 @@
<p class="tag-source">
<a href="utils_patcher.js.html" class="button">View Source</a>
<span>
<a href="utils_patcher.js.html">utils/patcher.js</a>, <a href="utils_patcher.js.html#line42">line 42</a>
<a href="utils_patcher.js.html">utils/patcher.js</a>, <a href="utils_patcher.js.html#line45">line 45</a>
</span>
</p>
@ -839,6 +862,13 @@
<dt class="tag-tutorial">Tutorials:</dt>
<dd class="tag-tutorial">
<ul>
<li><a href="tutorial-patchingBefore.html">Patching Before</a></li>
</ul>
</dd>
@ -849,7 +879,7 @@
<p class="tag-source">
<a href="utils_patcher.js.html" class="button">View Source</a>
<span>
<a href="utils_patcher.js.html">utils/patcher.js</a>, <a href="utils_patcher.js.html#line20">line 20</a>
<a href="utils_patcher.js.html">utils/patcher.js</a>, <a href="utils_patcher.js.html#line21">line 21</a>
</span>
</p>
@ -1087,6 +1117,13 @@
<dt class="tag-tutorial">Tutorials:</dt>
<dd class="tag-tutorial">
<ul>
<li><a href="tutorial-patchingInstead.html">Patching Instead</a></li>
</ul>
</dd>
@ -1097,7 +1134,7 @@
<p class="tag-source">
<a href="utils_patcher.js.html" class="button">View Source</a>
<span>
<a href="utils_patcher.js.html">utils/patcher.js</a>, <a href="utils_patcher.js.html#line31">line 31</a>
<a href="utils_patcher.js.html">utils/patcher.js</a>, <a href="utils_patcher.js.html#line33">line 33</a>
</span>
</p>
@ -1360,6 +1397,13 @@
<dt class="tag-tutorial">Tutorials:</dt>
<dd class="tag-tutorial">
<ul>
<li><a href="tutorial-patching.html">Patching Functions</a></li>
</ul>
</dd>
@ -1370,7 +1414,7 @@
<p class="tag-source">
<a href="utils_patcher.js.html" class="button">View Source</a>
<span>
<a href="utils_patcher.js.html">utils/patcher.js</a>, <a href="utils_patcher.js.html#line66">line 66</a>
<a href="utils_patcher.js.html">utils/patcher.js</a>, <a href="utils_patcher.js.html#line70">line 70</a>
</span>
</p>
@ -1567,7 +1611,7 @@
<p class="tag-source">
<a href="utils_patcher.js.html" class="button">View Source</a>
<span>
<a href="utils_patcher.js.html">utils/patcher.js</a>, <a href="utils_patcher.js.html#line50">line 50</a>
<a href="utils_patcher.js.html">utils/patcher.js</a>, <a href="utils_patcher.js.html#line53">line 53</a>
</span>
</p>

View File

@ -56,6 +56,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a

View File

@ -56,6 +56,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a

View File

@ -56,6 +56,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a

View File

@ -56,6 +56,22 @@
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a

View File

@ -0,0 +1,133 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ittai Patching After</title>
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="./build/entry.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
<link type="text/css" rel="stylesheet" href="jsdoc.css">
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
<body class="layout small-header">
<div id="stickyNavbarOverlay"></div>
<div class="top-nav">
<div class="inner">
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
<div class="logo">
<a href="index.html">
<h1 class="navbar-item">Ittai Documentation</h1>
</a>
</div>
<div class="menu">
<div class="navigation">
<a
href="index.html"
class="link"
>
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a
class="link user-link "
href="https://github.com/Kyza/ittai"
>
GitHub
</a>
</div>
</div>
</div>
</div>
<div id="main">
<div
class="sidebar tutorials"
id="sidebarNav"
>
<div class="search-wrapper">
<input id="search" type="text" placeholder="Search docs..." class="input">
</div>
<nav>
<div class="category"><h3>Tutorials</h3><ul><li><a href="tutorial-patching.html">Patching Functions</a><ul><li><a href="tutorial-patching-before.html">Patching Before</a></li><li><a href="tutorial-patching-instead.html">Patching Instead</a></li><li><a href="tutorial-patching-after.html">Patching After</a></li></ul></li></ul></div>
</nav>
</div>
<div class="core" id="main-content-wrapper">
<div class="content">
<header class="page-title">
<p>Tutorial</p>
<h1>Patching After</h1>
</header>
<section>
<article>
<p>bruh</p>
</article>
</section>
</div>
</div>
<div id="side-nav" class="side-nav">
</div>
</div>
<script src="scripts/app.min.js"></script>
<script>PR.prettyPrint();</script>
<script src="scripts/linenumber.js"> </script>
<script src="scripts/search.js"> </script>
</body>
</html>

View File

@ -0,0 +1,133 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ittai Patching Before</title>
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="./build/entry.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
<link type="text/css" rel="stylesheet" href="jsdoc.css">
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
<body class="layout small-header">
<div id="stickyNavbarOverlay"></div>
<div class="top-nav">
<div class="inner">
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
<div class="logo">
<a href="index.html">
<h1 class="navbar-item">Ittai Documentation</h1>
</a>
</div>
<div class="menu">
<div class="navigation">
<a
href="index.html"
class="link"
>
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a
class="link user-link "
href="https://github.com/Kyza/ittai"
>
GitHub
</a>
</div>
</div>
</div>
</div>
<div id="main">
<div
class="sidebar tutorials"
id="sidebarNav"
>
<div class="search-wrapper">
<input id="search" type="text" placeholder="Search docs..." class="input">
</div>
<nav>
<div class="category"><h3>Tutorials</h3><ul><li><a href="tutorial-patching.html">Patching Functions</a><ul><li><a href="tutorial-patching-before.html">Patching Before</a></li><li><a href="tutorial-patching-instead.html">Patching Instead</a></li><li><a href="tutorial-patching-after.html">Patching After</a></li></ul></li></ul></div>
</nav>
</div>
<div class="core" id="main-content-wrapper">
<div class="content">
<header class="page-title">
<p>Tutorial</p>
<h1>Patching Before</h1>
</header>
<section>
<article>
<p>bruh</p>
</article>
</section>
</div>
</div>
<div id="side-nav" class="side-nav">
</div>
</div>
<script src="scripts/app.min.js"></script>
<script>PR.prettyPrint();</script>
<script src="scripts/linenumber.js"> </script>
<script src="scripts/search.js"> </script>
</body>
</html>

View File

@ -0,0 +1,133 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ittai Patching Instead</title>
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="./build/entry.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
<link type="text/css" rel="stylesheet" href="jsdoc.css">
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
<body class="layout small-header">
<div id="stickyNavbarOverlay"></div>
<div class="top-nav">
<div class="inner">
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
<div class="logo">
<a href="index.html">
<h1 class="navbar-item">Ittai Documentation</h1>
</a>
</div>
<div class="menu">
<div class="navigation">
<a
href="index.html"
class="link"
>
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a
class="link user-link "
href="https://github.com/Kyza/ittai"
>
GitHub
</a>
</div>
</div>
</div>
</div>
<div id="main">
<div
class="sidebar tutorials"
id="sidebarNav"
>
<div class="search-wrapper">
<input id="search" type="text" placeholder="Search docs..." class="input">
</div>
<nav>
<div class="category"><h3>Tutorials</h3><ul><li><a href="tutorial-patching.html">Patching Functions</a><ul><li><a href="tutorial-patching-before.html">Patching Before</a></li><li><a href="tutorial-patching-instead.html">Patching Instead</a></li><li><a href="tutorial-patching-after.html">Patching After</a></li></ul></li></ul></div>
</nav>
</div>
<div class="core" id="main-content-wrapper">
<div class="content">
<header class="page-title">
<p>Tutorial</p>
<h1>Patching Instead</h1>
</header>
<section>
<article>
<p>bruh</p>
</article>
</section>
</div>
</div>
<div id="side-nav" class="side-nav">
</div>
</div>
<script src="scripts/app.min.js"></script>
<script>PR.prettyPrint();</script>
<script src="scripts/linenumber.js"> </script>
<script src="scripts/search.js"> </script>
</body>
</html>

178
docs/tutorial-patching.html Normal file
View File

@ -0,0 +1,178 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ittai Patching Functions</title>
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="./build/entry.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
<link type="text/css" rel="stylesheet" href="jsdoc.css">
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
<body class="layout small-header">
<div id="stickyNavbarOverlay"></div>
<div class="top-nav">
<div class="inner">
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
<div class="logo">
<a href="index.html">
<h1 class="navbar-item">Ittai Documentation</h1>
</a>
</div>
<div class="menu">
<div class="navigation">
<a
href="index.html"
class="link"
>
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a
class="link user-link "
href="https://github.com/Kyza/ittai"
>
GitHub
</a>
</div>
</div>
</div>
</div>
<div id="main">
<div
class="sidebar tutorials"
id="sidebarNav"
>
<div class="search-wrapper">
<input id="search" type="text" placeholder="Search docs..." class="input">
</div>
<nav>
<div class="category"><h3>Tutorials</h3><ul><li><a href="tutorial-patching.html">Patching Functions</a><ul><li><a href="tutorial-patchingBefore.html">Patching Before</a></li><li><a href="tutorial-patchingInstead.html">Patching Instead</a></li><li><a href="tutorial-patchingAfter.html">Patching After</a></li></ul></li></ul></div>
</nav>
</div>
<div class="core" id="main-content-wrapper">
<div class="content">
<header class="page-title">
<p>Tutorial</p>
<h1>Patching Functions</h1>
</header>
<section>
<article>
<p><a href="module-utils_patcher.html#.patch"><code>Patch</code></a>ing functions is a common way to inject code into Discord. Ittai provides three types of patches.</p>
<ul>
<li><a href="module-utils_patcher.html#.before"><code>Before</code></a> runs your code before the function is executed.</li>
<li><a href="module-utils_patcher.html#.instead"><code>Instead</code></a> Runs your code instead of the function.</li>
<li><a href="module-utils_patcher.html#.after"><code>After</code></a> runs your code after the function is executed.</li>
</ul>
<p><a href="module-utils_patcher.html#.before"><code>module:utils/patcher.before</code></a>, <a href="module-utils_patcher.html#.instead"><code>utils/patcher.instead</code></a>, and <a href="module-utils_patcher.html#.after"><code>module:utils/patcher.after</code></a> are also shorthand functions available in the patcher.</p>
<p>Ittai will automatically unpatch all of your functions when the plugin stops, so no need to worry about forgetting and leaving a patch hanging in the void.</p>
<p>Here's a basic example of how to use Ittai's patcher.</p>
<pre class="prettyprint source lang-js"><code>const obj = {
f: () => {
console.log(&quot;x&quot;);
},
};
/*
* x
*/
obj.f();
// Patch the function and save the patch for later.
const beforePatch = ittai.utils.patcher.patch(
&quot;patch-test&quot;,
obj,
&quot;f&quot;,
&quot;before&quot;,
() => {
console.log(&quot;Before patch!&quot;);
}
);
/*
* Before patch!
* x
*/
obj.f();
// Unpatch the function.
beforePatch.unpatch();
/*
* x
*/
obj.f();
</code></pre>
<p>You can also add multiple patches and combine patches of different types together.</p>
</article>
</section>
</div>
</div>
<div id="side-nav" class="side-nav">
</div>
</div>
<script src="scripts/app.min.js"></script>
<script>PR.prettyPrint();</script>
<script src="scripts/linenumber.js"> </script>
<script src="scripts/search.js"> </script>
</body>
</html>

View File

@ -0,0 +1,162 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ittai Patching After</title>
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="./build/entry.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
<link type="text/css" rel="stylesheet" href="jsdoc.css">
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
<body class="layout small-header">
<div id="stickyNavbarOverlay"></div>
<div class="top-nav">
<div class="inner">
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
<div class="logo">
<a href="index.html">
<h1 class="navbar-item">Ittai Documentation</h1>
</a>
</div>
<div class="menu">
<div class="navigation">
<a
href="index.html"
class="link"
>
API Documentation
</a>
<div class="dropdown is-hoverable is-right">
<a class="dropdown-trigger link">
Tutorials
<i class="fas fa-chevron-down fa-xs"></i>
</a>
<div class="dropdown-menu">
<div class="dropdown-content">
<a class="dropdown-item" href="tutorial-patching.html">
Patching Functions
</a>
</div>
</div>
</div>
<a
class="link user-link "
href="https://github.com/Kyza/ittai"
>
GitHub
</a>
</div>
</div>
</div>
</div>
<div id="main">
<div
class="sidebar tutorials"
id="sidebarNav"
>
<div class="search-wrapper">
<input id="search" type="text" placeholder="Search docs..." class="input">
</div>
<nav>
<div class="category"><h3>Tutorials</h3><ul><li><a href="tutorial-patching.html">Patching Functions</a><ul><li><a href="tutorial-patchingBefore.html">Patching Before</a></li><li><a href="tutorial-patchingInstead.html">Patching Instead</a></li><li><a href="tutorial-patchingAfter.html">Patching After</a></li></ul></li></ul></div>
</nav>
</div>
<div class="core" id="main-content-wrapper">
<div class="content">
<header class="page-title">
<p>Tutorial</p>
<h1>Patching After</h1>
</header>
<section>
<article>
<pre class="prettyprint source lang-js"><code>const obj = {
f: () => {
console.log(&quot;x&quot;);
},
};
/*
* x
*/
obj.f();
// Patch the function and save the patch for later.
const afterPatch = ittai.utils.patcher.after(&quot;patch-test&quot;, obj, &quot;f&quot;, () => {
console.log(&quot;After patch!&quot;);
});
/*
* x
* After patch!
*/
obj.f();
// Unpatch the function.
afterPatch.unpatch();
/*
* x
*/
obj.f();
</code></pre>
</article>
</section>
</div>
</div>
<div id="side-nav" class="side-nav">
</div>
</div>
<script src="scripts/app.min.js"></script>
<script>PR.prettyPrint();</script>
<script src="scripts/linenumber.js"> </script>
<script src="scripts/search.js"> </script>
</body>
</html>