CGLA Overview

3/1/2022, 11:43:40 PM

目前為 2022-03-02 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        CGLA Overview
// @namespace   Violentmonkey Scripts
// @match       https://www.candygirlla.com/
// @grant       none
// @version     1.0
// @author      -
// @description 3/1/2022, 11:43:40 PM
// @license     MIT
// ==/UserScript==

async function fetchProfile(url) {
  let res = await fetch(url)
  let text = await res.text()
  let parser = new DOMParser()
  let doc = parser.parseFromString(text, 'text/html')
  let els = doc.querySelectorAll('main div[data-testid=richTextElement]')
  let profile = els[1].textContent
  return profile.replace(/\n\n/g, "\n")
}

function addProfileOverlay(a, content) {
  let pre = document.createElement('PRE')
  pre.className = 'overlay'
  pre.innerHTML = content
  a.appendChild(pre)
}

async function fetchAll() {
  let as = document.querySelectorAll('a[data-testid=linkElement]._2tcsV')
  for (let i = 0; i < as.length; i++) {
    let profile = await fetchProfile(as[i].href)
    addProfileOverlay(as[i], profile)
  }
}

let css = `
pre.overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  margin: 1.5em;
  padding: 0.5em;
  border-radius: 8px;
  
  color: white;
  background: rgba(60, 40, 50, 0.75);
}
`
let style = document.createElement("style");
style.type = "text/css";
style.appendChild(document.createTextNode(css));
document.head.appendChild(style);

unsafeWindow.fetchProfile = fetchProfile
unsafeWindow.addProfileOverlay = addProfileOverlay
unsafeWindow.fetchAll = fetchAll
setTimeout(fetchAll, 3000)