syphonx-core
Version:
SyphonX is a template-driven solution for extracting data from HTML in a highly efficient way. It combines the power of jQuery, Regular Expressions, and Javascript into a declarative template-driven format that extracts and reshapes HTML data into JSON.
39 lines • 1.54 kB
JavaScript
export function unpatch(keys) {
const iframe = document.createElement("iframe");
iframe.style.display = "none";
document.body.appendChild(iframe);
if (iframe.contentWindow) {
const contentWindow = iframe.contentWindow;
for (const key of keys) {
if (!key.includes(".")) {
const obj = contentWindow[key];
if (obj) {
const descriptor = Object.getOwnPropertyDescriptor(contentWindow, key);
if (descriptor)
Object.defineProperty(window, key, descriptor);
}
}
else {
const parts = key.split(".");
const objectType = parts.slice(0, -1).join(".");
const method = parts[parts.length - 1];
let obj = contentWindow;
for (const part of objectType.split('.')) {
obj = obj[part];
}
if (obj) {
const descriptor = Object.getOwnPropertyDescriptor(obj, method);
if (descriptor) {
let targetObj = window;
for (const part of objectType.split('.')) {
targetObj = targetObj[part];
}
Object.defineProperty(targetObj, method, descriptor);
}
}
}
}
}
document.body.removeChild(iframe);
}
//# sourceMappingURL=unpatch.js.map