首页 > 解决方案 > Chrome 扩展 100% 无法检测到

问题描述

我正在开发一个特定站点绝对无法检测到的 Chrome 扩展程序。

只需检查一下,在 2020 年,如果我没有向页面中注入任何 DOM/JS/内容,并且 web_accessible_resources 未在 manifest.json 中定义,则网站无法检测扩展。

据我所知,Chrome 正在将“拒绝加载 ...”错误直接记录到 DevTools 控制台,绕过控制台。* api

测试代码,看看我是否可以挂钩 fetch 触发的“拒绝加载..”错误 - 看起来你不能。

<script>
    const clog = console.log
    console.log = function(x) {
        clog('x: ',x)
    }
    const cerror = console.error
    console.error = function(x) {
        cerror('error: ',x)
    }
  window.fetch('chrome-extension://jifpbeccnghkjeaalbbjmodiffmgedin/options.js',{method: 'get'})
    .then(response => response.text()).then(body => console.log(body))
    .catch(err => console.log(err))

</script>

在此处输入图像描述

我认为 frame->addMessageToConsole 的策略代码使用绕过了控制台。* API

https://chromium.googlesource.com/chromium/src/+/8747c1d912e10bbb8fe746ff6a06bb5a3d067efc/chrome/renderer/extensions/resource_request_policy.cc#89

if (!is_empty_origin && !is_own_resource &&
        !is_dev_tools && !transition_allowed && !is_error_page) {
      std::string message = base::StringPrintf(
          "Denying load of %s. Resources must be listed in the "
          "web_accessible_resources manifest key in order to be loaded by "
          "pages outside the extension.",
          resource_url.spec().c_str());
      frame->addMessageToConsole(
          blink::WebConsoleMessage(blink::WebConsoleMessage::LevelError,
                                    blink::WebString::fromUTF8(message)));
      return false;
    }

标签: google-chrome-extension

解决方案


推荐阅读