Chrome 扩展:在页面上仅显示图像(无文本)

Chrome Extension: Show Images Only (No Text) on Page

是否可以编写 Chrome 扩展程序,在启用插件后仅在页面上显示图像(隐藏所有文本)?

有可用的插件可以隐藏所有图像。我需要相反的东西:一个只有图像的页面,所有文本都隐藏了。

理想情况下,此行为也应限制在页面上的某些位置(例如,在特定 DIV 内),但这不是必需的。

如果您想隐藏所有 html 标签但 img 那么,是的,这是可能的,而且很容易做到。您可以使用 content style 覆盖目标页面的 CSS 并隐藏除图像标签以外的所有内容。

以下是您的操作方法:

manifest.json:

{
    "name": "Test extension",
    "version": "0.0.1",
    "manifest_version": 2,
    "description": "Some description",
    "icons": {
        "16": "images/icon-16.png",
        "128": "images/icon-128.png"
    },
    "default_locale": "en",
    "content_scripts": [
        {
            "matches": [
                "http://*/*",
                "https://*/*"
            ],
            "css" : [
                "styles/contentstyle.css"
            ],
            "run_at": "document_end"
        }
    ]
}

scripts/contentstyle.css

body {
    visibility: hidden;
}

* img {
    visibility: visible;
}

请注意,此 CRX 不会显示设置为 background-image 到 CSS 的图像,只会显示 img 标签。