CGLA Overview

Add an information overview to each profile pic on the home page.

As of 2022-03-04. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        CGLA Overview
// @namespace   Violentmonkey Scripts
// @match       https://www.candygirlla.com/
// @grant       none
// @version     1.1
// @author      -
// @description Add an information overview to each profile pic on the home page.
// @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][target=_self]')
  for (let i = 0; i < as.length; i++) {
    let a = as[i]
    let url = new URL(a.href)
    if (url.pathname === '/') continue
    let profile = await fetchProfile(a.href)
    addProfileOverlay(a, profile)
  }
}

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

//for debugging
//unsafeWindow.fetchProfile = fetchProfile
//unsafeWindow.addProfileOverlay = addProfileOverlay
//unsafeWindow.fetchAll = fetchAll

const wait = 3000
setTimeout(fetchAll, wait)

window.addEventListener('popstate', () => {
  if (location.pathname === '/') {
    const pres = document.querySelectorAll('pre.overlay')
    if (pres.length === 0) {
      setTimeout(fetchAll, wait)
    }
  }
})