better check for plugins wrapper removal
This commit is contained in:
parent
8d1dcf74fe
commit
85b7715c5d
@ -247,15 +247,25 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
if (!file.endsWith("user.js")) return "";
|
if (!file.endsWith("user.js")) return "";
|
||||||
String js = fileToString(file, asset);
|
String js = fileToString(file, asset);
|
||||||
if (js == "false") return "";
|
if (js == "false") return "";
|
||||||
// remove the wrapper function
|
String wrapper_start = "function wrapper() {";
|
||||||
|
String wrapper_end = "} // wrapper end";
|
||||||
|
String injection_code = "// inject code into site context\n" +
|
||||||
|
"var script = document.createElement('script');\n" +
|
||||||
|
"script.appendChild(document.createTextNode('('+ wrapper +')();'));\n" +
|
||||||
|
"(document.body || document.head || document.documentElement).appendChild(script);";
|
||||||
|
if (js.contains(wrapper_start) && js.contains(wrapper_end) && js.contains(injection_code)) {
|
||||||
js = js.replace("function wrapper() {", "");
|
js = js.replace("function wrapper() {", "");
|
||||||
|
// remove the wrapper function
|
||||||
js = js.replace("} // wrapper end", "");
|
js = js.replace("} // wrapper end", "");
|
||||||
// remove the injection (should be the last 4 lines)...will be done by the iitc script
|
// and the code injection
|
||||||
js = js.substring(0,js.lastIndexOf('\n'));
|
js = js.replace("// inject code into site context\n" +
|
||||||
js = js.substring(0,js.lastIndexOf('\n'));
|
"var script = document.createElement('script');\n" +
|
||||||
js = js.substring(0,js.lastIndexOf('\n'));
|
"script.appendChild(document.createTextNode('('+ wrapper +')();'));\n" +
|
||||||
js = js.substring(0,js.lastIndexOf('\n'));
|
"(document.body || document.head || document.documentElement).appendChild(script);", "");
|
||||||
js = js.substring(0,js.lastIndexOf('\n'));
|
} else {
|
||||||
|
Log.d("iitcm", "Removal of wrapper/injection code failed for " + file);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return js;
|
return js;
|
||||||
}
|
}
|
||||||
// Check every external resource if it’s okay to load it and maybe replace
|
// Check every external resource if it’s okay to load it and maybe replace
|
||||||
|
@ -131,5 +131,5 @@ if (window.iitcLoaded && typeof setup === 'function') {
|
|||||||
} // wrapper end
|
} // wrapper end
|
||||||
// inject code into site context
|
// inject code into site context
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.appendChild(document.createTextNode('(' + wrapper + ')();'));
|
script.appendChild(document.createTextNode('('+ wrapper +')();'));
|
||||||
(document.body || document.head || document.documentElement).appendChild(script);
|
(document.body || document.head || document.documentElement).appendChild(script);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user