/
frenchaccentedchars.user.js
68 lines (66 loc) · 1.49 KB
/
frenchaccentedchars.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
// ==UserScript==
// @name French Accented Characters
// @namespace http://tampermonkey.net/
// @version 0.0.6
// @description To allow typing of french characters.
// @author The Flamin' Taco
// @include *://chat.meta.stackoverflow.com/rooms/*
// @include *://chat.meta.stackexchange.com/rooms/*
// @include *://chat.stackexchange.com/rooms/*
// @include *://chat.stackoverflow.com/rooms/*
// @include *://chat.askubuntu.com/rooms/*
// @include *://chat.serverfault.com/rooms/*
// @run-at document-end
// @grant none
// ==/UserScript==
/* global $ */
(function() {
'use strict';
var combos = {
// L'accent aigu
"e//" : "é",
// L'accent grave
"a`" : "à",
"e`" : "è",
"u`" : "ù",
// L'accent circonflexe
"a\\^" : "â",
"e\\^" : "ê",
"i\\^" : "î",
"o\\^" : "ô",
"u\\^" : "û",
// La cédille
"c5" : "ç",
"c2" : "ç",
// Le tréma
'e"' : "ë",
'i"' : "ï",
'u"' : "ü",
// Qoutes
"<-<" : "«",
">->" : "»"
};
setInterval(function(){
var inp = $("#input");
for(var code in combos){
var cd = `(${code[0]})(${code.substr(1)})`;
inp.val(inp.val().replace(
RegExp(
"\\\\" + cd,
"ig"
),
(_,a,b)=> a + String.fromCharCode(0x200D) + b
));
}
for(var code in combos){
var cd = `(${code[0]})(${code.substr(1)})`;
inp.val(inp.val().replace(
RegExp(
cd,
"ig"
),
(_,a,b) => a==a.toUpperCase() ? combos[code].toUpperCase() : combos[code]
));
}
}, 100);
})();