Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
v2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Arubinu committed Feb 26, 2023
1 parent 92a4354 commit a58f3c9
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 39 deletions.
1 change: 1 addition & 0 deletions addons/twitch/addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function update_interface() {
'moderation:read',
'moderator:read:chat_settings',
'moderator:manage:automod',
'moderator:manage:announcements',
'moderator:manage:banned_users',
'moderator:manage:blocked_terms',
'moderator:manage:chat_settings',
Expand Down
14 changes: 13 additions & 1 deletion addons/twitch/twurple.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,17 @@ const methods = {
}

api_client.moderation.deleteChatMessages(user.id, user.id, messageId);
},
announce: async (userName, message, color) => {
const user = await getChannelUser(userName || channel.name);
if (!user) {
return false;
}

api_client.chat.sendAnnouncement(user.id, user.id, {
//color: '', // blue | green | orange | purple | primary
message
});
}
};

Expand Down Expand Up @@ -1216,7 +1227,6 @@ async function exec(type, name, args) {
const prefix_channel = [
'action',
'addVip',
'announce',
'ban',
'clear',
'deleteMessage',
Expand All @@ -1228,6 +1238,7 @@ async function exec(type, name, args) {
'raid',
'removeVip',
'runCommercial',
'sendAnnouncement',
'timeout',
'unhostOutside',
'unmod',
Expand All @@ -1244,6 +1255,7 @@ async function exec(type, name, args) {
c = methods;
}

console.log('twitch exec:', name, args);
if (c) {
let result;
if (args && args.length) {
Expand Down
3 changes: 3 additions & 0 deletions env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"NODE_ENV": "development"
}
17 changes: 15 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,11 @@ function create_window() {
configs.scripts[id] = scripts[id].config;
}

//win.webContents.openDevTools();
if (process.env.NODE_TOOLS) {
win.webContents.openDevTools();
}
win.webContents.executeJavaScript('console.log("user gesture fired");', true);
win.webContents.send('init', { menus, configs });
win.webContents.send('init', { menus, configs, mode: (process.env.NODE_ENV || 'production') });

if (Notification.isSupported()) {
(new Notification({
Expand All @@ -229,6 +231,12 @@ function create_window() {
}
});

win.on('will-navigate', (event, cmd) => {
if (cmd === 'browser-backward' || cmd === 'browser-forward') {
event.preventDefault();
}
})

win.on('close', event => {
event.preventDefault();
win.hide();
Expand Down Expand Up @@ -633,6 +641,11 @@ const logpath = (process.env.PORTABLE_EXECUTABLE_DIR ? process.env.PORTABLE_EXEC
elog.transports.file.resolvePath = () => path.join(logpath, 'ScriptsManager.log');
Object.assign(console, elog.functions);

const env_file = path.join(__dirname, 'env.json');
if (fs.existsSync(env_file)) {
Object.assign(process.env, JSON.parse(fs.readFileSync(env_file, 'utf-8')));
}

app.whenReady().then(() => {
// init tray
tray = new Tray(APP_ICON);
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "Scripts-Manager",
"version": "2.0.2",
"version": "2.0.3",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron .",
"start": "cross-env NODE_TOOLS=1 electron .",
"lint": "eslint --max-warnings=0 .",
"lint-fix": "eslint --max-warnings=0 --fix .",
"build": "electron-builder build --win portable"
"prebuild": "electron-builder build --win portable",
"build": "electron-builder build --config.files=\"!env.json\" --win portable"
},
"repository": "https://github.com/electron/electron-quick-start",
"keywords": [
Expand All @@ -21,6 +22,7 @@
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"cross-env": "^7.0.3",
"electron": "^19.0.6",
"eslint": "^8.33.0"
},
Expand Down
14 changes: 8 additions & 6 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ class Bluetooth {

ipcRenderer.on('init', (event, data) => {
let index = 0;
const list = document.querySelector('.menu');
const iframe = document.querySelector('.content > iframe');
const list = document.querySelector('.menu'),
iframe = document.querySelector('.content > iframe');

// define iframe height
setInterval(() => {
Expand All @@ -416,8 +416,8 @@ ipcRenderer.on('init', (event, data) => {

// menu generation
const add_ul = (type, name, parent) => {
const li = document.createElement('li');
const ul = document.createElement('ul');
const li = document.createElement('li'),
ul = document.createElement('ul');

li.appendChild(ul);
parent.appendChild(li);
Expand All @@ -426,8 +426,8 @@ ipcRenderer.on('init', (event, data) => {
};

const add_li = (type, id, name, parent) => {
const a = document.createElement('a');
const li = document.createElement('li');
const a = document.createElement('a'),
li = document.createElement('li');

a.innerText = name;
a.setAttribute('data-target', `${type}:${id}`);
Expand Down Expand Up @@ -692,6 +692,8 @@ ipcRenderer.on('init', (event, data) => {
// to main
ipcRenderer.invoke('manager', target);
}, 10);

document.body.setAttribute('mode', data.mode);
});

// click on menu link
Expand Down
3 changes: 3 additions & 0 deletions public/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ html, body {
width: 100%;
min-height: 100%;
}
body[mode="development"] .lateral-menu > section {
background-color: #b70f0f;
}
.lateral-menu > section > .hero-body {
flex-direction: column;
align-items: inherit !important;
Expand Down
65 changes: 58 additions & 7 deletions scripts/multi-actions/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,26 @@ <h4>Module name :</h4>
</div>
</div>

<div class="modal edit-value">
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title"></p>
<button class="delete" aria-label="close"></button>
</header>
<section class="modal-card-body">
<div class="content">
<h4><span class="value-name"></span> :</h4>
</div>
<input type="text" class="input has-text-centered" />
</section>
<footer class="modal-card-foot is-justify-content-right">
<button class="button is-success">Confirm</button>
<button class="button" aria-label="close">Cancel</button>
</footer>
</div>
</div>

<div class="container">
<section class="hero is-small has-background-grey-dark">
<div class="hero-body">
Expand Down Expand Up @@ -538,11 +558,12 @@ <h5 class="py-1 px-5" style="background-color: rgba(0, 0, 0, .2)">
</div>

<script type="text/javascript">
const drawflow = document.querySelector('.box-drawflow');
const selector = document.querySelector('.modules');
const editor = new Drawflow(drawflow);
const drawflow = document.querySelector('.box-drawflow'),
selector = document.querySelector('.modules'),
editor = new Drawflow(drawflow);

let _config = false;
let edit_target = false;
window.editor = editor;
editor.draggable_inputs = false;

Expand Down Expand Up @@ -650,8 +671,8 @@ <h5 class="py-1 px-5" style="background-color: rgba(0, 0, 0, .2)">
});

document.querySelector('i.add-module').addEventListener('click', event => {
const elem = document.querySelector('div.add-module');
const input = elem.querySelector('input');
const elem = document.querySelector('div.add-module'),
input = elem.querySelector('input');

elem.classList.add('is-active');
input.value = '';
Expand All @@ -677,8 +698,8 @@ <h5 class="py-1 px-5" style="background-color: rgba(0, 0, 0, .2)">
});

document.querySelector('i.edit-module').addEventListener('click', event => {
const elem = document.querySelector('div.edit-module');
const input = elem.querySelector('input');
const elem = document.querySelector('div.edit-module'),
input = elem.querySelector('input');

updateDisabled();

Expand Down Expand Up @@ -727,6 +748,36 @@ <h5 class="py-1 px-5" style="background-color: rgba(0, 0, 0, .2)">
}
});

document.addEventListener('dblclick', () => {
const node = get_node(event.target);
if (node && event.target.nodeName.toLowerCase() === 'input' && event.target.getAttribute('type') === 'text') {
const elem = document.querySelector('div.edit-value'),
input = elem.querySelector('input'),
title = elem.querySelector('.modal-card-title'),
name = elem.querySelector('.value-name');

elem.classList.add('is-active');
title.innerText = window.get_block(node.html).title;
name.innerText = get_name(event.target);
input.value = event.target.value;
input.focus();

edit_target = event.target;
}
});

document.querySelector('div.edit-value .is-success').addEventListener('click', event => {
const node = get_node(event.target),
elem = document.querySelector('div.edit-value'),
input = elem.querySelector('input'),
modal = event.target.closest('.modal');

modal.classList.remove('is-active');
edit_target.value = input.value;
edit_target.dispatchEvent(new Event('change', { bubbles: true }));
edit_target = false;
});

const section_filter = event => {
event.target.closest('.content').classList.toggle(`${event.target.getAttribute('section-filter')}-filter`);
};
Expand Down
34 changes: 28 additions & 6 deletions scripts/multi-actions/libs/drawflow.blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,19 @@ document.addEventListener('DOMContentLoaded', () => {
}
}

function get_name(elem) {
elem = level_elem(elem);
while (elem.previousElementSibling && elem.previousElementSibling.nodeName.toLowerCase() !== 'p') {
elem = elem.previousElementSibling;
}

if (elem && elem.previousElementSibling) {
return elem.previousElementSibling.innerText.trim();
}
}

function set_value(elem, value) {
if (elem.classList.contains('no-eye')) {
if (elem.closest('.no-eye')) {
return;
}

Expand Down Expand Up @@ -809,13 +820,14 @@ document.addEventListener('DOMContentLoaded', () => {
button_on = elem.querySelector(`${selectors.name}.button-on`),
button_toggle = elem.querySelector(`${selectors.name}.button-toggle`),
button_off = elem.querySelector(`${selectors.name}.button-off`),
change_state = (state, save, state_string) => {
change_state = (state, save, state_string, force) => {
button_on.classList.toggle('is-active', (toggle ? (state === 'on') : state));
button_off.classList.toggle('is-active', (toggle ? (state === 'off') : !state));
if (button_toggle) {
button_toggle.classList.toggle('is-active', (state === 'toggle'));
}

const original = data[arg];
if (save) {
data[arg] = state;
set_data(data);
Expand All @@ -835,7 +847,7 @@ document.addEventListener('DOMContentLoaded', () => {

set_value(inputs[0], state_string);

if (callback) {
if (callback && (force || original !== state)) {
callback(state);
}
};
Expand All @@ -860,9 +872,9 @@ document.addEventListener('DOMContentLoaded', () => {
}
}

change_state(value, undefined, name);
change_state(value, undefined, name, true);
} else {
change_state(inputs[0].checked);
change_state(inputs[0].checked, undefined, undefined, true);
}
}
}
Expand Down Expand Up @@ -1972,7 +1984,9 @@ document.addEventListener('DOMContentLoaded', () => {
tooltip: 'Twitch - Info',
icon: 'info',
inputs: 1,
outputs: 1
outputs: 1,
body: bodys.text('Channel'),
update: functions.trim
},
'inputs-twitch-info': {
type: 'twitch',
Expand Down Expand Up @@ -2602,6 +2616,12 @@ document.addEventListener('DOMContentLoaded', () => {
delete_connections(node);
});

function get_block(name) {
if (typeof blocks[name] !== 'undefined') {
return Object.assign({}, blocks[name]);
}
}

function block_exists(name) {
return typeof blocks[name] !== 'undefined';
}
Expand Down Expand Up @@ -2905,7 +2925,9 @@ document.addEventListener('DOMContentLoaded', () => {
}
});

window.get_name = get_name;
window.get_node = get_node;
window.get_block = get_block;
window.block_exists = block_exists;
window.filter_nodes = filter_nodes;
window.import_nodes = import_nodes;
Expand Down
Loading

0 comments on commit a58f3c9

Please sign in to comment.