Advertisement
usotsuki_KR

DLsite IP Viewer 1.0.0

Feb 6th, 2025
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         DLsite IP Viewer
  3. // @version      1.0.0
  4. // @description  DLsite 페이지에서 사용자의 IP와 국가 정보를 표시, 검열된 국가일 경우 경고를 표시한다.
  5. // @match        https://www.dlsite.com/maniax*
  6. // @match        https://www.dlsite.com/maniax/*
  7. // @author       로리마망
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     'use strict';
  13.  
  14.     // 현재 IP를 가져온다.
  15.     async function getIPInfo() {
  16.         try {
  17.             // ipwhois.app API 사용 (CORS 지원 및 국가 정보 제공)
  18.             const response = await fetch('https://ipwhois.app/json/');
  19.             if (!response.ok) throw new Error('Failed to fetch IP info');
  20.  
  21.             const data = await response.json();
  22.             return {
  23.                 ip: data.ip || 'Unknown',
  24.                 country: data.country_code || 'Unknown'
  25.             };
  26.         } catch (error) {
  27.             console.error('Error fetching IP info:', error);
  28.             return {
  29.                 ip: 'Unknown',
  30.                 country: 'Unknown'
  31.             };
  32.         }
  33.     }
  34.  
  35.     // 국가 코드에 맞는 국기 이미지 URL 반환
  36.     function getFlagImageURL(countryCode) {
  37.         return `https://flagcdn.com/w20/${countryCode.toLowerCase()}.png`;
  38.     }
  39.  
  40.     // p.header_description 부분의 텍스트를 긴빠이쳐서 IP 정보를 추가
  41.     async function insertIPInfo() {
  42.         const ipInfo = await getIPInfo();
  43.         if (!ipInfo) return;
  44.  
  45.         const descriptionElement = document.querySelector('p.header_description');
  46.         if (descriptionElement) {
  47.             const flagImg = `<img src='${getFlagImageURL(ipInfo.country)}' width='20' height='15' style='vertical-align: middle; border: 1px solid #000000; display: inline-block;'>`;
  48.             let ipText = `${flagImg} ${ipInfo.ip}`;
  49.  
  50.             switch (ipInfo.country.toUpperCase()) {
  51.                 case 'KR': // 한국
  52.                     ipText = `${flagImg} <b style='color: red;'>${ipInfo.ip} ⚠️ 검열 중! 일부 작품이 보이지 않을 수 있습니다! ⚠️</b>`;
  53.                     break;
  54.                 case 'JP': // 일본
  55.                     ipText = `${flagImg} ${ipInfo.ip} 👍`;
  56.                     break;
  57.                 default: // 기타 국가
  58.                     ipText = `${flagImg} ${ipInfo.ip}`;
  59.                     break;
  60.             }
  61.  
  62.             descriptionElement.innerHTML += `&nbsp; ${ipText}`;
  63.         }
  64.     }
  65.  
  66.     insertIPInfo();
  67. })();
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement