MCPcopy Index your code
hub / github.com/XIU2/UserScript / createDocumentByString

Function createDocumentByString

Autopage.user.js:2406–2426  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

2404 return parents
2405 }
2406 function createDocumentByString(e) {
2407 if (e) {
2408 if ('HTML' !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, 'application/xhtml+xml');
2409 var t;
2410 try { t = (new DOMParser).parseFromString(e, 'text/html');} catch (e) {}
2411 if (t) return t;
2412 if (document.implementation.createHTMLDocument) {
2413 t = document.implementation.createHTMLDocument('ADocument');
2414 } else {
2415 try {((t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)), t.documentElement.appendChild(t.createElement('head')), t.documentElement.appendChild(t.createElement('body')));} catch (e) {}
2416 }
2417 if (t) {
2418 var r = document.createRange(),
2419 n = r.createContextualFragment(e);
2420 r.selectNodeContents(document.body);
2421 t.body.appendChild(n);
2422 for (var a, o = { TITLE: !0, META: !0, LINK: !0, STYLE: !0, BASE: !0}, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a);
2423 return t;
2424 }
2425 } else console.error('没有找到要转成 DOM 的字符串', e);
2426 }
2427
2428
2429 // 兼容不支持 GM_openInTab 的油猴脚本管理器

Callers 2

getPageEFunction · 0.85
getPageE_Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected