@@ -555,6 +555,10 @@ window.proxyPrefixPathRegexp = new RegExp("${proxyPrefixPathRegexpStr}");
555555 // interceptElementAttribute(element, "src", "mp_");
556556 // interceptElementSrcset(element);
557557 } else if ( element instanceof HTMLScriptElement ) {
558+ if ( element . hasAttribute ( "integrity" ) ) {
559+ element . removeAttribute ( "integrity" ) ;
560+ }
561+
558562 if ( element . getAttribute ( "type" ) === "module" ) {
559563 interceptElementAttribute ( element , "src" , "esm_" ) ;
560564 } else {
@@ -672,6 +676,13 @@ window.proxyPrefixPathRegexp = new RegExp("${proxyPrefixPathRegexpStr}");
672676 const elements = doc . querySelectorAll ( "*" ) ;
673677 elements . forEach ( ( element ) => {
674678 if ( element instanceof HTMLElement ) {
679+ if (
680+ element instanceof HTMLScriptElement &&
681+ element . hasAttribute ( "integrity" )
682+ ) {
683+ element . removeAttribute ( "integrity" ) ;
684+ }
685+
675686 const urlAttributes = [ "src" , "href" , "action" , "data-src" ] ;
676687 urlAttributes . forEach ( ( attr ) => {
677688 if ( element . hasAttribute ( attr ) ) {
@@ -968,6 +979,10 @@ window.proxyPrefixPathRegexp = new RegExp("${proxyPrefixPathRegexpStr}");
968979 value : string
969980 ) : void {
970981 try {
982+ if ( name === "integrity" && this instanceof HTMLScriptElement ) {
983+ return ;
984+ }
985+
971986 const urlAttributes = [ "src" , "href" , "action" , "data-src" ] ;
972987 if ( urlAttributes . includes ( name ) && typeof value === "string" ) {
973988 let mod = "mp_" ;
@@ -988,19 +1003,6 @@ window.proxyPrefixPathRegexp = new RegExp("${proxyPrefixPathRegexpStr}");
9881003 return originalSetAttribute . call ( this , name , rewrittenValue ) ;
9891004 }
9901005
991- // if (name === "srcset" && typeof value === "string") {
992- // const parts = value.split(",").map((part) => {
993- // const [url, ...descriptors] = part.trim().split(/\s+/);
994- // if (url && !url.startsWith("data:")) {
995- // const rewrittenUrl = rewriteUrl(url, "mp_");
996- // return [rewrittenUrl, ...descriptors].join(" ");
997- // }
998- // return part;
999- // });
1000-
1001- // return originalSetAttribute.call(this, name, parts.join(", "));
1002- // }
1003-
10041006 if (
10051007 name === "style" &&
10061008 typeof value === "string" &&
0 commit comments