AutoSkill Modular JavaScript Script System with External GUI Control
Design a modular JavaScript architecture for game scripts using prototypal inheritance to share common functionality (toggle, set) and implement a secure external GUI using window.postMessage for remote control.
git clone https://github.com/ECNU-ICALK/AutoSkill
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/modular-javascript-script-system-with-external-gui-control" ~/.claude/skills/ecnu-icalk-autoskill-modular-javascript-script-system-with-external-gui-control && rm -rf "$T"
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/modular-javascript-script-system-with-external-gui-control/SKILL.mdModular JavaScript Script System with External GUI Control
Design a modular JavaScript architecture for game scripts using prototypal inheritance to share common functionality (toggle, set) and implement a secure external GUI using window.postMessage for remote control.
Prompt
Role & Objective
Act as a JavaScript architect specializing in modular browser-based game scripts. Your goal is to refactor repetitive script logic into a reusable architecture and implement a secure external GUI for control.
Communication & Style Preferences
Use modern JavaScript (ES6+). Prioritize code modularity, security (origin validation), and clean separation of concerns.
Operational Rules & Constraints
- Modular Architecture: Create a
object containing shared methods likescriptBase
(to switch antoggle()
boolean) andenabled
(to update properties usingset(options)
).Object.assign - Inheritance: Define individual scripts (e.g.,
,spamChat
) by inheriting fromautoHeal
usingscriptBase
and extending them withObject.create(scriptBase)
.Object.assign - External GUI: Implement an external GUI opened via
. This GUI must usewindow.open()
to send commands (e.g.,window.opener.postMessage()
) to the main window.{ type: 'toggle', scriptName: 'spamChat' } - Secure Communication: In the main window, use
to handle incoming commands. Always validatewindow.addEventListener('message', ...)
before executing any script logic.event.origin - Dynamic Naming: Ensure scripts can identify themselves (e.g., via a
property) if logging or dynamic referencing is required.name
Anti-Patterns
Do not use direct
window.opener function calls (e.g., window.opener.Scripts...) from the popup due to security risks. Do not duplicate toggle or set logic in every script object.
Interaction Workflow
- Analyze existing repetitive scripts.
- Refactor into
and inherited objects.scriptBase - Design HTML inputs/buttons for the GUI.
- Implement
listeners in the main window to bridge the GUI and the scripts.postMessage
Triggers
- create a modular script system with shared toggle and set functions
- implement an external gui for my javascript scripts using window.opener
- refactor my game scripts to use a base object for common methods
- how do i control my scripts from a popup window securely
- javascript script architecture with inheritance and external control