MCPcopy
hub / github.com/theajack/disable-devtool / checkScriptUse

Function checkScriptUse

src/plugins/script-use.ts:7–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5 */
6
7export function checkScriptUse () {
8 if ('undefined' === typeof window || !window.document) return null;
9 const dom = document.querySelector('[disable-devtool-auto]');
10 if (!dom) {
11 return null;
12 }
13
14 const boolAttrs = [
15 'disable-menu', 'disable-select', 'disable-copy',
16 'disable-cut', 'disable-paste', 'clear-log'
17 ];
18
19 const intAttrs = ['interval'];
20
21 const json: Record<string, any> = {};
22 [
23 'md5', 'url', 'tk-name', 'detectors',
24 ...boolAttrs, ...intAttrs
25 ].forEach(name => {
26 let value: any = dom.getAttribute(name);
27 if (value !== null) {
28 if (intAttrs.indexOf(name) !== -1) {
29 value = parseInt(value);
30 } else if (boolAttrs.indexOf(name) !== -1) {
31 value = value === 'false' ? false : true;
32 } else if (name === 'detector') {
33 if (value !== 'all') {
34 value = value.split(' ');
35 }
36 }
37 json[formatName(name)] = value;
38 }
39 });
40 return json;
41}
42
43function formatName (name: string) {
44 if (name.indexOf('-') === -1) {

Callers 1

main.tsFile · 0.90

Calls 1

formatNameFunction · 0.85

Tested by

no test coverage detected