forked from magicoflolis/Userscript-Plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.js
More file actions
44 lines (44 loc) · 1.8 KB
/
Copy pathheader.js
File metadata and controls
44 lines (44 loc) · 1.8 KB
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
[[metadata]]
(() => {
'use strict';
/******************************************************************************/
const inIframe = (() => {
try {
return window.self !== window.top;
} catch {
return true;
}
})();
if (inIframe) return;
let userjs = self.userjs;
/**
* Skip text/plain documents, based on uBlock Origin `vapi.js` file
*
* [source code](https://github.com/gorhill/uBlock/blob/68962453ff6eec7ff109615a738beb8699b9844a/platform/common/vapi.js#L35)
*/
if (
(document instanceof Document ||
(document instanceof XMLDocument && document.createElement('div') instanceof HTMLDivElement)) &&
/^text\/html|^application\/(xhtml|xml)/.test(document.contentType || '') === true &&
(self.userjs instanceof Object === false || userjs.UserJS !== true)
) {
userjs = self.userjs = { UserJS: true };
} else {
console.error('[%cMagic Userscript+%c] %cERROR','color: rgb(29, 155, 240);','','color: rgb(249, 24, 128);', `MIME type is not a document, got "${document.contentType || ''}"`);
}
if (!(typeof userjs === 'object' && userjs.UserJS)) return;
{
/** Native implementation exists */
const excludePolicy = [
'outlook.office.com'
];
const hostname = location?.hostname || '';
if (window.trustedTypes && window.trustedTypes.createPolicy && !hostname.includes(excludePolicy)) window.trustedTypes.createPolicy('default', { createHTML: (string) => string, createScript: (string) => string, createScriptURL: (string) => string });
}
/** [i18n directory](https://github.com/magicoflolis/Userscript-Plus/tree/master/src/_locales) */
const translations = [[languageList]];
/** [source code](https://github.com/magicoflolis/Userscript-Plus/blob/master/src/sass/_main.scss) */
const main_css = `[[mainCSS]]`;
/******************************************************************************/
[[code]]
})();