Last active
February 28, 2025 08:53
-
-
Save argf013/588e0fb22aacf2898a8855996f05b00a to your computer and use it in GitHub Desktop.
Script Shortcut Aris
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let isListenerActive = true; | |
// Helper function to find and click an anchor element | |
function clickAnchorElements(elements) { | |
elements.forEach((element) => element.click()); | |
} | |
// Helper function to find and click elements by class name | |
function clickElementsByClass(elements, className) { | |
elements.forEach((element) => { | |
if (element.querySelectorAll) { | |
element.querySelectorAll(`.${className}`).forEach((el) => el.click()); | |
} | |
}); | |
} | |
// Function to click the first matching link with specific text content | |
function clickLinkByText(links, text) { | |
let clicked = false; | |
links.forEach((link) => { | |
if (!clicked && link.textContent.trim() === text) { | |
link.click(); | |
clicked = true; | |
} | |
}); | |
} | |
// Function to handle element click by id and aria-label | |
function handleElementByIdOrAttribute(id, ariaLabel) { | |
const element = document.querySelector(`#${id}[aria-label="${ariaLabel}"]`); | |
if (element) { | |
element.click(); | |
} else { | |
console.error( | |
`Element with id="${id}" and aria-label="${ariaLabel}" not found.` | |
); | |
} | |
} | |
// Main keydown listener function | |
function mainKeydownListener(event) { | |
if (!isListenerActive) return; // Ignore if listener is inactive | |
const links = document.querySelectorAll('a.link'); | |
switch (event.key.toLowerCase()) { | |
case 'e': | |
// First show all inline edit actions | |
document | |
.querySelectorAll('.inlineEdit-actions') | |
.forEach((el) => (el.style.display = 'block')); | |
// Click the inline edit action button | |
document.getElementById('gwt-debug-inlineEdit-action-btn').click(); | |
// Find and click element with aria-label="Place attribute" | |
document.querySelector('[aria-label="Place attribute"]').click(); | |
break; | |
case 'q': | |
if (event.altKey) clickLinkByText(links, 'Organizational unit lane'); | |
break; | |
case 'c': | |
handleKeyPress('Control', 'symbolsPanel-symbolsRow-icon-name-wrapper'); | |
break; | |
case 'x': | |
handleKeyPress('Risk', 'symbolsPanel-symbolsRow-icon-name-wrapper'); | |
break; | |
case 'r': | |
if (event.altKey) clickLinkByText(links, 'Role lane'); | |
else clickLinkByText(links, 'Lane to the right'); | |
break; | |
case 'l': | |
if (event.altKey) handleButtonPress('Layout'); | |
else clickLinkByText(links, 'Lane to the left'); | |
break; | |
case 'd': | |
handleKeyPress('Document', 'symbolsPanel-symbolsRow-icon-name-wrapper'); | |
break; | |
case 'i': | |
handleButtonPress('Create connection'); | |
break; | |
case 'h': | |
handleButtonPress('Horizontal space'); | |
break; | |
case 'v': | |
handleButtonPress('Vertical space'); | |
break; | |
case 'a': | |
if (event.altKey) clickLinkByText(links, 'Application system type lane'); | |
// Open attribute placement toolbar | |
else if (event.shiftKey) { | |
const element = document.getElementById( | |
'gwt-debug-attributeplacement-toolbar' | |
); | |
if (element) { | |
let startElement = document.querySelector( | |
'a.link[data-target="#gwt-uid-251"]' | |
); | |
if (startElement) { | |
startElement.click(); | |
} | |
element.className = 'btn-group open active'; | |
element.setAttribute('aria-expanded', 'true'); | |
element.setAttribute('expanded', 'true'); | |
} | |
} else | |
handleKeyPress( | |
'Application system type', | |
'symbolsPanel-symbolsRow-icon-name-wrapper' | |
); | |
break; | |
case 't': | |
handleKeyPress('Task', 'symbolsPanel-symbolsRow-icon-name-wrapper'); | |
break; | |
case 'g': | |
handleKeyPress('Gateway', 'symbolsPanel-symbolsRow-icon-name-wrapper'); | |
break; | |
case '|': | |
case '\\': | |
clickLinkByText(links, 'Attribute placement'); | |
break; | |
} | |
} | |
// Activate or deactivate the event listener | |
document.addEventListener('keydown', (event) => { | |
if (event.ctrlKey && event.key === ']') { | |
isListenerActive = false; | |
console.log('Event listener deactivated.'); | |
} else if (event.ctrlKey && event.key === '[') { | |
isListenerActive = true; | |
console.log('Event listener activated.'); | |
} | |
}); | |
// Main event listener for keydown | |
document.addEventListener('keydown', mainKeydownListener); | |
// Handle element click by title and class name | |
function handleKeyPress(title, className, isAnchor = false) { | |
const elements = document.querySelectorAll(`[title="${title}"]`); | |
if (!elements.length) { | |
console.error(`Element with title="${title}" not found.`); | |
return; | |
} | |
isAnchor | |
? clickAnchorElements(elements) | |
: clickElementsByClass(elements, className); | |
} | |
// Handle button click by aria-label | |
function handleButtonPress(ariaLabel) { | |
const button = document.querySelector(`[aria-label="${ariaLabel}"]`); | |
if (button) { | |
button.click(); | |
} else { | |
console.error(`Button with aria-label="${ariaLabel}" not found.`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to Use This Script for Shortcuts
Open ARIS:
Open Developer Tools (F12):
F12
on your keyboard to open the Developer Tools in your browser.Go to the Console Tab:
Copy and Paste the Code:
allow pasting
and press Enter before proceeding.Press Enter:
Use the Keyboard Shortcuts:
Keyboard Shortcuts Documentation
Basic Controls
Ctrl + [
- Activate event listenerCtrl + ]
- Deactivate event listenerLane Operations
Alt + Q
- Add Organizational unit laneAlt + R
- Add Role laneAlt + A
- Add Application system type laneR
- Add Lane to the rightL
- Add Lane to the leftElement Creation
C
- Add Control elementX
- Add Risk elementD
- Add Document elementA
- Add Application system type (HoldShift
for Attribute Placement Toolbar)T
- Add Task elementG
- Add Gateway elementE
- Open Inline Edit Actions and Place AttributeLayout & Connections
I
- Create connectionH
- Add Horizontal spaceV
- Add Vertical space|
or\
- Open Attribute placement toolbarAlt + L
- Open Layout menuNotes
Ctrl + [
to activate andCtrl + ]
to deactivate the shortcuts.