Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name DLsite IP Viewer
- // @version 1.0.0
- // @description DLsite 페이지에서 사용자의 IP와 국가 정보를 표시, 검열된 국가일 경우 경고를 표시한다.
- // @match https://www.dlsite.com/maniax*
- // @match https://www.dlsite.com/maniax/*
- // @author 로리마망
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // 현재 IP를 가져온다.
- async function getIPInfo() {
- try {
- // ipwhois.app API 사용 (CORS 지원 및 국가 정보 제공)
- const response = await fetch('https://ipwhois.app/json/');
- if (!response.ok) throw new Error('Failed to fetch IP info');
- const data = await response.json();
- return {
- ip: data.ip || 'Unknown',
- country: data.country_code || 'Unknown'
- };
- } catch (error) {
- console.error('Error fetching IP info:', error);
- return {
- ip: 'Unknown',
- country: 'Unknown'
- };
- }
- }
- // 국가 코드에 맞는 국기 이미지 URL 반환
- function getFlagImageURL(countryCode) {
- return `https://flagcdn.com/w20/${countryCode.toLowerCase()}.png`;
- }
- // p.header_description 부분의 텍스트를 긴빠이쳐서 IP 정보를 추가
- async function insertIPInfo() {
- const ipInfo = await getIPInfo();
- if (!ipInfo) return;
- const descriptionElement = document.querySelector('p.header_description');
- if (descriptionElement) {
- const flagImg = `<img src='${getFlagImageURL(ipInfo.country)}' width='20' height='15' style='vertical-align: middle; border: 1px solid #000000; display: inline-block;'>`;
- let ipText = `${flagImg} ${ipInfo.ip}`;
- switch (ipInfo.country.toUpperCase()) {
- case 'KR': // 한국
- ipText = `${flagImg} <b style='color: red;'>${ipInfo.ip} ⚠️ 검열 중! 일부 작품이 보이지 않을 수 있습니다! ⚠️</b>`;
- break;
- case 'JP': // 일본
- ipText = `${flagImg} ${ipInfo.ip} 👍`;
- break;
- default: // 기타 국가
- ipText = `${flagImg} ${ipInfo.ip}`;
- break;
- }
- descriptionElement.innerHTML += ` ${ipText}`;
- }
- }
- insertIPInfo();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement