-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarquee-motto.user.js
48 lines (39 loc) · 1.15 KB
/
marquee-motto.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// ==UserScript==
// @name Marquee Motto
// @namespace https://github.com/skychatorg/
// @version 1.0
// @description Userscript which sets a circular motto, similar to the good 'old <marquee> tag
// @author 7PH
// @grant none
// @match https://SKYCHAT_DOMAIN_NAME/*
// ==/UserScript==
/**
* Do NOT forget to change the @match tag above
*/
/**
* Entire motto to show
*/
const MOTTO_CONTENT = 'My awesome motto'.toUpperCase();
/**
* Maximum motto length to show at a specific time
*/
const MOTTO_LENGTH = 8;
(async function() {
'use strict';
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const interval = 1000;
const client = Vue.prototype.$client;
const start = async () => {
let position = 0;
while (true) {
const part = MOTTO_CONTENT.substr(position, MOTTO_LENGTH).trim();
const command = '/motto ' + part;
client.sendMessage(command);
await sleep(interval);
if (position ++ > MOTTO_CONTENT.length) {
position = 0;
}
}
};
client.on('config', start);
})();