跳到正文
← API 文档

Publishers

SDK 接入与用户同意

SDK 会采集 URL 和搜索查询,因此依据 GDPR(第 6 条)和 ePrivacy(第 5(3) 条)需要用户的明确同意。在用户点击「允许」之前,SDK 不创建标识符、不存储事件、也不与服务器通信。您的扩展功能不受该选择影响。

Manifest V3 Opt-in Shadow DOM

安装

在控制台中:扩展 → SDK → 「下载」。将压缩包解压到扩展根目录。

压缩包
intentd.min.js        带有您扩展密钥的 SDK —— 请勿重命名
intentd-consent.html  面向无 popup 扩展的同意页面
intentd-consent.js    该页面的脚本(MV3 禁止内联脚本)
manifest.json
{
  "manifest_version": 3,
  "background": { "service_worker": "background.js", "type": "module" },
  "action": { "default_popup": "popup.html" },
  "permissions": ["storage", "webNavigation", "tabs", "alarms", "unlimitedStorage"],
  "host_permissions": ["https://api.intentd.io/*"]
}
background.js
// background.js —— 第一行,顶层作用域
import './intentd.min.js';

API

方法用途
IntentD.mountConsent(element) 在没有同意时于 popup 中显示提示条。Promise<boolean>。
IntentD.hasConsent() 是否存在针对当前文本版本的同意。Promise<boolean>。
IntentD.getConsentState() 'approved' | 'declined' | null。
IntentD.grantConsent() 记录同意(来自您自己的界面)。
IntentD.revokeConsent() 撤回:停止采集,删除队列和安装标识符。
IntentD.openConsentTab() 手动打开同意标签页(或聚焦已打开的那个)。
IntentD.status() SDK 状态,包含 consent。

该决定只保存在当前浏览器配置文件的 chrome.storage.local 中:每台设备单独询问,服务器不记录谁在何时同意。随每个数据包发往服务器的只有同意文本的版本号。