blob: 1bc9a7d6d43c07dcc121db21eac32f18ddae4858 [file] [log] [blame]
avm999630bc113a2020-09-07 13:02:11 +02001function injectStylesheet(stylesheetName, attributes = {}) {
avm999634c1a6792020-08-31 21:30:42 +02002 var link = document.createElement('link');
3 link.setAttribute('rel', 'stylesheet');
4 link.setAttribute('href', stylesheetName);
avm999630bc113a2020-09-07 13:02:11 +02005 if ('media' in attributes) link.setAttribute('media', attributes['media']);
avm999634c1a6792020-08-31 21:30:42 +02006 document.head.appendChild(link);
7}
8
9function injectStyles(css) {
10 injectStylesheet('data:text/css;charset=UTF-8,' + encodeURIComponent(css));
11}
12
13function injectScript(scriptName) {
14 var script = document.createElement('script');
15 script.src = scriptName;
16 document.head.appendChild(script);
17}
avm99963943b8492020-08-31 23:40:43 +020018
19function escapeUsername(username) {
20 var quoteRegex = /"/g;
21 var commentRegex = /<!---->/g;
22 return username.replace(quoteRegex, '\\"').replace(commentRegex, '');
23}