Created
September 18, 2023 10:29
-
-
Save MShrimp4/677fc90e597d95acd87057aa33dec7d4 to your computer and use it in GitHub Desktop.
그래서 어느 엔진이라고?
This file contains hidden or 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 그래서 어느 엔진이라고? | |
// @namespace http://buttersc.one/ | |
// @version 0.1 | |
// @description 우우우 이상한 권한 요구하는 플러그인이다 무섭지 우우우 | |
// @author 갯가재 | |
// @match https://buttersc.one/ | |
// @match https://stella.place/ | |
// @match https://k.lapy.link/ | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=buttersc.one | |
// @connect * | |
// @grant GM.xmlHttpRequest | |
// ==/UserScript== | |
function replacer(key, value) { //https://stackoverflow.com/questions/29085197/how-do-you-json-stringify-an-es6-map | |
if(value instanceof Map) { | |
return { | |
dataType: 'Map', | |
value: Array.from(value.entries()), // or with spread: value: [...value] | |
}; | |
} else { | |
return value; | |
} | |
} | |
function reviver(key, value) { | |
if(typeof value === 'object' && value !== null) { | |
if (value.dataType === 'Map') { | |
return new Map(value.value); | |
} | |
} | |
return value; | |
} | |
(function() { | |
'use strict'; | |
const config = { attributes: true, childList: true, subtree: true }; | |
var domainMap = new Map(); | |
let savedDMAP = localStorage.getItem("domainMap"); | |
if (savedDMAP != null) { | |
domainMap = JSON.parse(savedDMAP, reviver); | |
console.log(`domainMap Loaded: ${domainMap.size} entries`) | |
} | |
var inverval_timer = setInterval(function() { | |
let sav = JSON.stringify(domainMap, replacer); | |
localStorage.setItem("domainMap", sav); | |
console.log(`domainMap Saved: ${domainMap.size} entries`) | |
}, 1000 * 60); | |
console.log('started'); | |
const callback = (mutLst, observer) => { | |
observer.disconnect(); | |
console.log("Something Changed"); | |
let elements = document.querySelectorAll('div.xBLVI span:nth-child(2)'); | |
for (let elem of elements) { | |
let parent = elem.parentNode; | |
let domain = (elem.innerText).substring(1); | |
if (parent.childElementCount > 2) { | |
continue; | |
} | |
if (domainMap.has(domain)) { | |
let entity = domainMap.get(domain); | |
parent.innerHTML = parent.innerHTML.concat(`<span style="opacity: 0.4;">(${entity})</span>`); | |
} | |
else { | |
GM.xmlHttpRequest({ | |
method: "GET", | |
url: `https://${domain}/.well-known/nodeinfo`, | |
onload: function(res) { | |
if (res.readyState != 4 || res.status != 200) { | |
return; | |
} | |
let j = JSON.parse(res.responseText); | |
GM.xmlHttpRequest({ | |
method: "GET", | |
url: j['links'][0]['href'], | |
onload: function(res) { | |
if (res.readyState != 4 || res.status != 200) { | |
return; | |
} | |
let j = JSON.parse(res.responseText); | |
let entity = j['software']['name']; | |
domainMap.set(domain, entity); | |
console.log(`${domain} => ${entity}`); | |
if (parent.childElementCount > 2) { | |
return; | |
} | |
parent.innerHTML = parent.innerHTML.concat(`<span style="opacity: 0.4;">(${entity})</span>`); | |
} | |
}); | |
} | |
}); | |
} | |
} | |
setTimeout(function(){ observer.observe(document.body, config); }, 1000); | |
}; | |
const observer = new MutationObserver(callback); | |
observer.observe(document.body, config); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment