세이프 서치 - 특정 키워드 검열 처리 > 그누보드5 스킨

그누보드5 스킨

좋은 댓글과 좋아요는 제작자에게 큰힘이 됩니다.

세이프 서치 - 특정 키워드 검열 처리 정보

전체검색 세이프 서치 - 특정 키워드 검열 처리

첨부파일

safe_search.zip (9.3K) 4회 다운로드 2023-11-02 08:00:42 포인트 차감225
테스트한 버전5.5.8.3.1
호환 가능 버전5.3이상 가능할 것으로 예상?

본문

아래의 코드를 원하는 곳에 삽입하세요.

 

---------------------------------23.11.04 이전 코드--------------------------------------

<script>

function getTextNodes(node){

    let all = [];

    for (node=node.firstChild;node;node=node.nextSibling){

        if (node.nodeType==3) all.push(node); // Node.TEXT_NODE

        else all = all.concat(getTextNodes(node));

    }

    return all;

}

let currentDomain = window.location.hostname;

let targetTextsUrl = `https://${currentDomain}/data.txt`;

fetch(targetTextsUrl)

  .then(response => response.text())

  .then(data => {

    let targetTexts = data.split('\n');

    let textNodes = getTextNodes(document.body);

    for(let node of textNodes) {

      let containsTargetText = targetTexts.some(target => node.nodeValue.includes(target));

      if(containsTargetText) {

        node.parentNode.style.filter = 'blur(10px)';

      }

   }

});            

</script>

 

 

===================================23.11.04에 수정된 코드, 이 코드를 사용해주세요.===============================

<?php
function loadTargetTexts() {
  $currentDomain = $_SERVER['HTTP_HOST'];
  $targetTextsUrl = "https://{$currentDomain}/data.txt";

  try {
    $data = file_get_contents($targetTextsUrl);
    $targetTexts = preg_split('/\r
|\r|
/', $data);
    $targetTexts = array_filter($targetTexts, 'trim');
    return $targetTexts;
  } catch (Exception $error) {
    echo "텍스트 파일을 불러오는 중 오류가 발생했습니다: ", $error->getMessage(), "
";
    return [];
  }
}
$targetTexts = loadTargetTexts();
echo "<script>var targetTexts = " . json_encode($targetTexts) . ";</script>";
?>

<script>
  function blurMatchingTexts(targetTexts) {
    let textNodes = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false); 
    let currentNode;
    while (currentNode = textNodes.nextNode()) {
      let nodeValue = currentNode.nodeValue.trim();
      if (targetTexts.includes(nodeValue)) {
        currentNode.parentElement.style.filter = "blur(5px)";
      }
    }
  }
  function initialize() {
    blurMatchingTexts(targetTexts);
    const observer = new MutationObserver(mutations => {
      blurMatchingTexts(targetTexts);
    }); 
    observer.observe(document.body, { subtree: true, childList: true, characterData: true });
  }
  window.addEventListener("load", initialize);
</script>

 

/search/search.skin.php에 삽입한다면 검색 시에만 검열을 하고,

head.skin.php에 삽입하면

사이트 전체에서 세이프 서치 - 특정 키워드가 블러처리되도록 할 수 있습니다.

 

설치방법은 

https://dsclub.kr/bbs/board.php?bo_table=code&wr_id=561 참고하세요.

 

기본 제공 데이터에는 강도 높은 비하발언과 성희롱적인 말, 정치적인 발언이 담겨있습니다. 주의해주세요.

 

관리자 페이지는 테블릿과 pc에 최적화 되어있습니다.

제작자의 동의 없는 무단 수정 및 배포를 금지합니다.

 

포인트 없이 다운로드: https://dsclub.kr/bbs/board.php?bo_table=zip&wr_id=61

추천
4

댓글 전체

data.txt에 너무 많은 데이터가 있으면 제대로 작동하지 않는 문제가 있네요, 최대한 빠른시간 내에 해결하도록 하겠습니다.

 

-11.04 해결됨

전체 2,436 |RSS
그누보드5 스킨 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT