1 2const getCSPNonce = () => { 3 const meta = document.querySelector('meta[name="csp-nonce"]'); 4 return meta ? meta.getAttribute('content') : ''; 5}; 6 const CSP_NONCE = getCSPNonce(); 7 // ð¥ æ ¸å¿ï¼ç嬿æ DOM èç¹å建ï¼åªè¦æ¯ style ç«å»å nonce 8 if (window.MutationObserver) { 9 const observer = new MutationObserver((mutations) => { 10 mutations.forEach(m => { 11 m.addedNodes.forEach(node => { 12 // åªè¦æ¯ style æ ç¾ï¼å¼ºå¶å nonce 13 if (node.tagName === 'STYLE') { 14 node.setAttribute('nonce', CSP_NONCE); 15 } 16 }); 17 }); 18 }); 19 20 // ç嬿´ä¸ª documentï¼æè·ææå¨æå建ç style 21 observer.observe(document.documentElement, { 22 subtree: true, 23 childList: true 24 }); 25 } 26 27 // å ¼å®¹èæµè§å¨ + 忥åå»ºåºæ¯ 28 document.createElement = (function(orig) { 29 return function(tag) { 30 const el = orig.call(this, tag); 31 if (tag === 'style') el.setAttribute('nonce', CSP_NONCE); 32 return el; 33 }; 34 })(document.createElement);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.