Last active
February 24, 2020 10:56
-
-
Save hadongsoo/bb3b9517f1099bc23bb6bd94d7448afc to your computer and use it in GitHub Desktop.
tgd.kr sometimes show blank streamer name fix manually
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name tgd_clip_page | |
// @namespace Violentmonkey Scripts | |
// @match https://tgd.kr/clips/* | |
// @exclude https://tgd.kr/clips/lists/* | |
// @grant none | |
// @version 1.0 | |
// @author - | |
// @description 2020. 2. 9. 오전 2:03:15 | |
// ==/UserScript== | |
// streamer Number get | |
(async ()=>{ | |
let numberStreamerList = { | |
"235491613":'MSFIIIRE', | |
"471919376":'텐텐2', | |
"125387632": "amouranth", | |
"130968411": "주펄", | |
"154028091": "novaruu", | |
"197406569": "TheNicoleT", | |
"232757351": "masitneungogooma", | |
"235491613": "MSFIIIRE", | |
"453339059": "꾸이랑", | |
"471919376": "텐텐2", | |
"491613782": "ehyuktv", | |
"491783967": "주아씨" | |
} | |
if (!localStorage.getItem("nStreamerList")) { | |
localStorage.setItem("nStreamerList", JSON.stringify(numberStreamerList)); | |
} | |
let nStreamerList = JSON.parse(localStorage.getItem("nStreamerList")); | |
let existStreamerInfo = await document.getElementById('clip-streamer-info'); | |
// console.log(window.location.search); | |
if (!existStreamerInfo && window.location.search){ | |
let urlSearch = window.location.search; | |
let urlGroup = urlSearch.match(/streamer_id=([0-9]{9})\&/); | |
let streamerNumber = Array.from(urlGroup)[1] | null; | |
let streamerName = streamerNumber; | |
for (var key in nStreamerList) { | |
if (nStreamerList.hasOwnProperty(key)) { | |
if (streamerNumber == key){ | |
// console.log(numberStreamerList[key]); | |
streamerName = nStreamerList[key]; | |
} | |
} | |
} | |
let prepareStreamerInputMarkup = ` | |
<div class="input-group"> | |
<input type="text" class="form-control" id="input_streamer_name" placeholder="${streamerNumber}" /> | |
</div> | |
`; | |
let prepareStreamerInfoMarkup = ` | |
<a href="/clips/lists?streamer_id=${streamerNumber}"> | |
<img src="https://static-cdn.jtvnw.net/user-default-pictures-uv/294c98b5-e34d-42cd-a8f0-140b72fba9b0-profile_image-300x300.png" alt="" class="img-circle"> | |
</a> | |
<div id="clip-streamer-name"> | |
<a href="/clips/lists?streamer_id=${streamerNumber}">${streamerName}</a> | |
${(!isNaN(streamerName)) ? prepareStreamerInputMarkup:""} | |
</div> | |
`; | |
let streamerInfoDiv = document.createElement("div"); | |
streamerInfoDiv.id ='clip-streamer-info'; | |
streamerInfoDiv.innerHTML = prepareStreamerInfoMarkup; | |
let clipArea = document.getElementById('clip-area'); | |
let clipCommentArea = clipArea.querySelector('#clip-comment-container'); | |
let clipHeaderArea = clipArea.querySelector('#clip-header'); | |
clipArea.insertBefore(streamerInfoDiv, clipCommentArea); | |
let input_streamer_name = await document.getElementById('input_streamer_name'); | |
if (input_streamer_name) { | |
input_streamer_name.addEventListener('keypress', (ev)=> { | |
if (ev.key == "Enter") { | |
nStreamerList[streamerNumber] = input_streamer_name.value; | |
localStorage.setItem("nStreamerList", JSON.stringify(nStreamerList)); | |
location.reload(); | |
} | |
}) | |
} | |
// console.log('스트리머 넘버 매칭 완료 : ',nStreamerList); | |
} else { | |
// console.log('있음 끝'); | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment