(selector, contextNode = document, toE = document.body)
| 2315 | } |
| 2316 | // 插入 <Script> |
| 2317 | function insScript(selector, contextNode = document, toE = document.body) { |
| 2318 | let scriptElems = contextNode; |
| 2319 | if (selector) { |
| 2320 | if (contextNode instanceof Array) { |
| 2321 | scriptElems = []; contextNode.forEach(function (one) {scriptElems = scriptElems.concat(getAll(selector, one, one));}) |
| 2322 | } else { |
| 2323 | scriptElems = getAll(selector, contextNode, contextNode); |
| 2324 | } |
| 2325 | } |
| 2326 | |
| 2327 | scriptElems.forEach(function (one) { |
| 2328 | if (one.tagName === 'SCRIPT') { |
| 2329 | if (one.src) { |
| 2330 | toE.appendChild(document.createElement('script')).src = one.src; |
| 2331 | } else { |
| 2332 | toE.appendChild(document.createElement('script')).textContent = one.textContent;//.replaceAll('document.write', ''); |
| 2333 | } |
| 2334 | } |
| 2335 | }); |
| 2336 | } |
| 2337 | // 插入 <Style> |
| 2338 | function insStyle(style) { |
| 2339 | if (style.indexOf('{') === -1){style += '{display: none !important;}'} |
no test coverage detected