-
Notifications
You must be signed in to change notification settings - Fork 6
/
youcompleteme.user.js
69 lines (62 loc) · 2.05 KB
/
youcompleteme.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// ==UserScript==
// @name you complete me!
// @namespace https://volafile.org/
// @author topkuk productions
// @icon https://volafile.org/favicon.ico
// @version 8
// @description So you can better ignore people
// @match https://volafile.org/r/*
// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @require https://cdn.jsdelivr.net/gh/RealDolos/volascripts@6879f622f45d2b79dd9f004754c28ffa0075a12b/dry.js
// @run-at document-idle
// @grant none
// ==/UserScript==
/* global GM, dry, console */
"use strict";
console.log(
"running", GM.info.script.name, GM.info.script.version, dry.version);
const always = [
"RealDolos", "TheJIDF", "Kreg", "roboCOP", "Lain",
"Heisenb3rg", "Red", "dad", "MoDChatbot", "bain", "lmmortal",
"someguy1992", "Szeraton", "NineBanger87", "Starsheep",
"Dongmaster", "MercWMouth", "ptc",
];
let never = new Set([
"DavidBowie", "Record",
"News", "Network", "MOTD", "System", "CucklordSupreme", "Report", "Log",
"VolaPG",
]);
const limit = 30;
never = new Set(Array.from(never).map(e => e.toUpperCase()));
const filter = function(current, e) {
const u = e.toUpperCase();
if (this.has(u) || never.has(u) || current === u) {
return false;
}
this.add(u);
return true;
};
const addn = dry.replaceLate("chat.chatInput", "addSuggestion",
function(orig, str) {
const current = dry.exts.user.info.nick.toUpperCase();
const e = this.suggestions;
str = str.toString();
const ustr = str.toUpperCase();
if (!str || never.has(ustr) || e.indexOf(str) === 0 || ustr === current) {
return;
}
// Delay stuff a bit to avoid people stealing completes;
// suggestion by the Redard
setTimeout(() => {
let newSuggestions = [...[str, ...e].slice(0, limit), ...always];
try {
newSuggestions = newSuggestions.filter(filter.bind(new Set(), current));
this.suggestions = newSuggestions;
}
catch (ex) {
console.error(ex);
}
}, 1000);
});
addn("");
setTimeout(() => addn(""), 1000);