// ==UserScript== // @name 아카라이브 깡계확인 및 핫딜챈 비율표시 // @namespace http://kemomimi.com/ // @version 1.4.1 // @description 깡계확인 스크립트(글 5개나 댓글 5개 미만 표시) 및 핫딜챈 한정 핫딜챈 작성글 비율 표시 // @match https://arca.live/b/*/* // @grant GM_xmlhttpRequest // @connect arca.live // @grant GM_getValue // @grant GM_setValue // @downloadURL none // ==/UserScript== // 화이트리스트 추가 function addItem(newItem) { let savedArray = JSON.parse(GM_getValue("whlteArray", "[]")); savedArray.push(newItem); GM_setValue("whlteArray", JSON.stringify(savedArray)); } // 화이트리스트 삭제 function deleteItem(itemToDelete) { let savedArray = JSON.parse(GM_getValue("whlteArray", "[]")); let index = savedArray.indexOf(itemToDelete); if (index > -1) { savedArray.splice(index, 1); GM_setValue("whlteArray", JSON.stringify(savedArray)); } } function removeUnsafe() { if (window.location.href.includes('/hotdeal/')) { const link = document.querySelector('table a'); let href = link.getAttribute('href'); let title = link.getAttribute('title'); let text = link.textContent; href = href.replace('https://unsafelink.com/', ''); const newLink = document.createElement('a'); newLink.href = href; newLink.title = title; newLink.textContent = text; newLink.target = "_blank"; newLink.className = "external"; newLink.rel = "external nofollow noopener noreferrer"; link.parentNode.replaceChild(newLink, link); } } const firstLink = document.querySelector('.info-row .user-info a'); const dataFilterValue = firstLink.getAttribute('data-filter'); var showFlag = true; const button = document.createElement('button'); let savedArray = JSON.parse(GM_getValue("whlteArray", "[]")); if (!savedArray.includes(dataFilterValue)) { button.textContent = '➕'; button.title = "핫딜비율&깡계 표시 숨기기" }else{ button.textContent = '➖'; button.title = "핫딜비율&깡계 표시하기" showFlag = false; } button.style.cursor = 'pointer'; button.style.backgroundColor = 'transparent'; button.style.border = 'none'; button.addEventListener('click', function() { let savedArray = JSON.parse(GM_getValue("whlteArray", "[]")); if (!savedArray.includes(dataFilterValue)) { addItem(dataFilterValue); button.textContent = '✅화이트리스트에 추가됨'; setTimeout(() => location.reload(), 1000); } else { deleteItem(dataFilterValue); button.textContent = '✅화이트리스트에서 제거됨'; setTimeout(() => location.reload(), 1000); } }); const member = document.querySelector('.member-info'); if (!showFlag){ member.appendChild(button); }else if (firstLink && showFlag) { const targetURL = firstLink.href; // GET 요청 보내기 GM_xmlhttpRequest({ method: 'GET', url: targetURL, onload: function(response) { removeUnsafe(); const htmlData = response.responseText; const parser = new DOMParser(); const doc = parser.parseFromString(htmlData, 'text/html'); if(doc.querySelectorAll('.error-code').length >=1){ firstLink.style.fontSize = '17px'; firstLink.style.fontWeight = 'bold'; firstLink.style.color = 'red'; firstLink.style.textDecoration = 'line-through'; firstLink.textContent += ' (삭제된 계정)'; member.appendChild(button); }else{ const cardBlockElement = doc.querySelector('.card-block'); const childNodes = cardBlockElement.childNodes; var post = 0 var coment = 0 var hotdeal = 0 var washyourid = 0 var flag = 0 for (const node of childNodes) { if (node.nodeType === Node.ELEMENT_NODE) { if(node.className == "clearfix"){ flag+=1 } if(node.className== "user-recent" && flag==0){ post+=1 const colTitleNodes = node.querySelectorAll('.col-title span'); colTitleNodes.forEach(span => { if(span.textContent.trim() === "핫딜 채널") { hotdeal += 1; } if(span.textContent.trim() === "세탁 채널") { washyourid += 1; } }); }else if(node.className== "user-recent" && flag==1){ coment+=1 } } } if (window.location.href.includes('/hotdeal/')) { // 핫딜챈 var hotdealRatio = ((hotdeal/post)*100).toFixed(0) if(post<=5 || coment<=5){ firstLink.style.fontSize = '17px'; firstLink.style.fontWeight = 'bold'; firstLink.style.color = 'red'; firstLink.textContent += ' (핫딜챈 비율:'+hotdealRatio+'% 최근 글:'+post+' 댓글:'+coment+')'; member.appendChild(button); }else if(washyourid>=1){ firstLink.style.fontSize = '17px'; firstLink.style.fontWeight = 'bold'; firstLink.style.color = 'red'; var washedHotdealRatio = ((hotdeal/(post-washyourid))*100).toFixed(0) firstLink.textContent += ' (세탁챈 글:'+washyourid+' 핫딜챈 비율:'+washedHotdealRatio+'%)'; member.appendChild(button); }else{ if (hotdealRatio >= 70){ firstLink.style.color = 'red'; } if(hotdealRatio >= 90){ firstLink.style.fontWeight = 'bold'; firstLink.style.fontSize = '17px'; } firstLink.textContent += ' (핫딜챈 비율: '+hotdealRatio+'%)'; member.appendChild(button); } } else if(washyourid>=1){ firstLink.style.fontSize = '17px'; firstLink.style.fontWeight = 'bold'; firstLink.style.color = 'red'; firstLink.textContent += ' (세탁챈 글:'+washyourid+' 글:'+(post-washyourid)+' 댓글:'+coment+')'; member.appendChild(button); } else if(post<=5 || coment<=5){ firstLink.style.fontSize = '17px'; firstLink.style.fontWeight = 'bold'; firstLink.style.color = 'red'; firstLink.textContent += ' (최근 글:'+post+' 댓글:'+coment+')'; member.appendChild(button); }else{ //firstLink.textContent += ' (최근 글:'+post+' 댓글:'+coment+')'; } } } }); } else { //console.log('링크를 찾을 수 없음'); }