# 크롬 익스텐션이 설치되는 경로는 다음과 같다
/Users/USERNAME/Library/Application Support/Google/Chrome/Default/Extensions

웹 페이지가 확장 리소스를 읽을 수 있는 건 web_accessible_resources 에 선언된 것뿐이다.1

function isInstalled(extensionId) {
  return new Promise((resolve, reject) => {
    const img = new Image()

    img.src = `chrome-extension://${extensionId}/icon-128.png` // 해당 리소스가 `web_accessible_resources`에 선언되어 있는지 확인이 필요하다.
    img.onload = () => {
      resolve(true)
    }
    img.onerror = () => {
      reject()
    }
  })
}

Footnotes

  1. Manifest - Web Accessible Resources - Chrome for Developers: “By default no resources are web accessible, as this allows a malicious website to fingerprint extensions that a user has installed…” ↩

`#207`