> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rev.iq/llms.txt
> Use this file to discover all available pages before exploring further.

# setAdsEnabled

> 设置页面上广告的显示状态 Set visibility of ads on the page

export const domain = (() => {
  const placeholder = "your-domain.com";
  if (typeof window !== "undefined" && !globalThis.__revDomainSetup) {
    globalThis.__revDomainSetup = true;
    function textNodes(node) {
      if (node.nodeType === Node.TEXT_NODE) return [node];
      const nodes = [];
      for (const child of node.childNodes) {
        nodes.push(...textNodes(child));
      }
      return nodes;
    }
    function anchorNodes(node) {
      if (node.nodeType === Node.ELEMENT_NODE && node.tagName === "A") return [node];
      const nodes = [];
      for (const child of node.childNodes) {
        nodes.push(...anchorNodes(child));
      }
      return nodes;
    }
    const domain = globalThis.__revDomain || new URLSearchParams(globalThis.location.search).get('domain') || "yourdomain.com";
    globalThis.__revDomain = domain;
    if (globalThis.__revDomainObs) return;
    const obs = globalThis.__revDomainObs || new MutationObserver(mutations => {
      for (const {addedNodes, removedNodes, target} of mutations) {
        for (const node of [...addedNodes, target]) {
          if (node instanceof HTMLScriptElement) continue;
          if (node instanceof HTMLStyleElement) continue;
          for (const textNode of textNodes(node)) {
            if (textNode.nodeValue && textNode.nodeValue.includes(placeholder)) {
              setTimeout(() => {
                textNode.nodeValue = textNode.nodeValue.replace(placeholder, domain);
              }, 100);
            }
          }
          for (const anchorNode of anchorNodes(node)) {
            if (anchorNode.href && anchorNode.href.includes(placeholder)) {
              setTimeout(() => {
                anchorNode.href = anchorNode.href.replace(placeholder, domain);
              }, 100);
            }
          }
        }
      }
    });
    obs.observe(document.body, {
      childList: true,
      subtree: true
    });
  }
  return placeholder;
})();

<Note>
  此功能适用于付费用户等场景。不过，如果某些页面完全不需要展示广告，建议直接省略RevIQ脚本，而非通过此函数禁用。This can be useful for paid users, though it
  is recommended to omit the RevIQ script entirely on pages where ads are not
  desired.
</Note>

<ParamField path="enabled" type="boolean" required>
  是否启用广告 Whether ads should be enabled
</ParamField>

<CodeGroup>
  ```js 禁用广告 Disable ads theme={null}
  reviq.setAdsEnabled(false);
  ```

  ```js 启用广告 Enable ads theme={null}
  // 仅在广告此前已被禁用的情况下需要调用 Only needed if ads were previously disabled
  reviq.setAdsEnabled(true);
  ```
</CodeGroup>
