> ## 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.

# 데스크톱 앱

> 몇 줄의 코드로 Electron 앱에 광고를 게재하세요

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;
})();

### 설치

rev-utils 라이브러리를 설치하여 Electron 설정에 광고 완전 호환성을 추가합니다.
패키지는 수시로 업데이트될 수 있습니다.

```sh theme={null}
npm i -D rev-utils@https://r2.reviq.app/rev-utils-v1.0.3.tgz
```

### 사용법

`new BrowserWindow`로 윈도우를 생성한 후, 윈도우와 `electron` 글로벌을
`setupRevUtils`에 전달합니다.

```js main.js theme={null}
const { setupRevUtils } = require("rev-utils");

// 여기서 글로벌 electron을 임포트하는 것에 주의하세요!
const electron = require("electron"); 
// 이 모듈 객체에서 디스트럭처링하여 임포트할 수 있습니다
const { BrowserWindow } = electron;

const myWindow = new BrowserWindow();

setupRevUtils(myWindow, electron);
```

<Info>
  내부적으로 `setupRevUtils`는 윈도우에 대해 두 가지 함수를 호출합니다

  * `setupLinkHandler`는 광고를 열고 (악의적인 동작을 차단합니다!)
  * `setUserAgent`는 User Agent 문자열에서 비표준 부분을 제거합니다. 이는
    IVT(무효 트래픽)로 플래그될 수 있습니다. <Tooltip tip="IVT 벤더는
    비표준 사용자 에이전트를 포함한 여러 신호를 확인하며, 자동화된 트래픽으로
    잘못 플래그할 수 있습니다"> \[?] </Tooltip>
</Info>
