customElements.define( 'x-frame-bypass', class extends HTMLIFrameElement { static get observedAttributes() { return ['src']; } constructor() { super(); } attributeChangedCallback() { this.load(this.src); } connectedCallback() { this.sandbox = '' + this.sandbox || 'allow-forms allow-modals allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation-by-user-activation'; // all except allow-top-navigation } load(url, options) { if (!url || !url.startsWith('http')) throw new Error(`Unable to load src ${url} does not start with http(s)://`); this.srcdoc = `
`; this.fetchProxy(url, options, 0) .then((res) => res.text()) .then((data) => { if (data) this.srcdoc = data.replace( /]*)>/i, `