Global killswitch system for WikiShield.
This module provides a simple polling mechanism to check a remote Wikipedia page for killswitch commands that can either disable WikiShield entirely or force a reload.
- Description:
Global killswitch system for WikiShield.
This module provides a simple polling mechanism to check a remote Wikipedia page for killswitch commands that can either disable WikiShield entirely or force a reload.
- Source:
Example
import { killswitch_status, startKillswitchPolling } from './core/killswitch.js';
// Check if WikiShield is disabled
if (killswitch_status.disabled) {
console.log("WikiShield is disabled by killswitch");
return;
}
// Start monitoring the killswitch
startKillswitchPolling(api);
Members
(static, constant) killswitch_config :Object
- Description:
Configuration for the killswitch polling system.
- Source:
Properties:
| Name | Type | Description |
|---|---|---|
killswitch_page |
string | Wikipedia page containing killswitch configuration JSON |
polling_interval |
number | How often to check the killswitch page (milliseconds) |
Configuration for the killswitch polling system.
Type:
- Object
Example
// To set up the killswitch, create a page at the configured location with this content:
// Page: User:LuniZunie/killswitch.js
// Content:
{
"disabled": false,
"forceReload": false
}
// To disable WikiShield:
{
"disabled": true,
"forceReload": false
}
// To force all users to reload:
{
"disabled": false,
"forceReload": true
}
(static, constant) killswitch_status :Object
- Description:
Killswitch status object with two simple options.
- Source:
Properties:
| Name | Type | Description |
|---|---|---|
disabled |
boolean | If true, WikiShield should not load or operate |
reload |
ReloadObject | Reload options |
Killswitch status object with two simple options.
Type:
- Object
Example
// Check if WikiShield is disabled
if (killswitch_status.disabled) {
console.log("WikiShield is disabled");
return;
}
Methods
(async, static) checkKillswitch(api) → {Promise.<Object>}
- Description:
Check the remote killswitch page and update the global killswitch status.
This function fetches the killswitch configuration page from Wikipedia, parses the JSON content, and updates the killswitch_status object. If forceReload is detected, it will reload the page immediately.
- Source:
Example
const status = await checkKillswitch(wikishield.api);
if (status.disabled) {
console.log("WikiShield has been disabled!");
}
Parameters:
| Name | Type | Description |
|---|---|---|
api |
WikiShieldAPI | The WikiShield API instance for fetching page content |
Returns:
The updated killswitch_status object
- Type
- Promise.<Object>
(static) startKillswitchPolling(api)
- Description:
Start polling the killswitch page at regular intervals.
This function begins a polling loop that checks the killswitch configuration at the interval specified in killswitch_config.
- Source:
Example
startKillswitchPolling(wikishield.api);
Parameters:
| Name | Type | Description |
|---|---|---|
api |
WikiShieldAPI | The WikiShield API instance for fetching page content |