| 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 的油猴脚本管理器 |