代码之家  ›  专栏  ›  技术社区  ›  graywolf

忽略firefox webextension中的x-frame-options

  •  0
  • graywolf  · 技术社区  · 6 年前

    我正在尝试将我的扩展从chrome移植到firefox,但是我有问题 带X帧选项。我的扩展非常简单,只需创建少量 iframes,等待它们加载,然后从加载的页面中提取一些数据。

    这一切都是很好的IT Chrome,但是在Firefox中我有一个问题,那就是页面 不加载到iframe中(可能是由于 X-Frame-Options: ALLOW-FROM XXX )

    铬合金

    "permissions": {
        "https://example.com/"
    }
    

    足以让浏览器忽略x-frame选项,但在firefox中 它仍然不起作用。

    那么,我如何才能强迫火狐忽略我的扩展的X帧选项(以及 它的页面?

    编辑:我只是想补充一点,因为我无论如何都在使用注入内容脚本(从帧中获取数据),我不想 需要 它在一个iframe中。我所需要的只是呈现页面,而不让用户看到它(所以新的选项卡等不是go/)。

    manifest.json

    {
      "manifest_version": 2,
      "name": "Iframe test",
      "description": "foobar",
      "version": "0.9.3",
      "browser_action": {
        "default_popup": "popup.html"
      },
      "permissions": [
        "activeTab",
        "https://jisho.org/"
      ]
    }
    

    popup.html

    <html>
        <head>
            <meta charset="UTF-8" />
        </head>
        <body>
            <iframe src="https://jisho.org"></iframe>
        </body>
    </html>
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   johnp    6 年前

    doesn't support

    webRequest webRequest.onHeadersReceived

    browser.webRequest.onHeadersReceived.addListener((details) => {
            let newHeaders = details.responseHeaders.filter(
                header => !header.name.toLowerCase().endsWith('frame-options')
            );
            return {responseHeaders: newHeaders};
        },
        {
            urls: [ 'https://jisho.org/*' ],
            types: [ 'sub_frame' ]
        },
        ['blocking', 'responseHeaders']
    );
    

    webRequestBlocking