Image Popup - humaniplex.com

View images on HX in a glightbox popup

目前為 2022-12-28 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Image Popup - humaniplex.com
// @namespace   Violentmonkey Scripts
// @match       https://www.humaniplex.com/*
// @grant       none
// @version     1.0.6
// @author      -
// @description View images on HX in a glightbox popup
// @license     MIT
// ==/UserScript==

let $head = document.querySelector('head')
let $link = document.createElement('link')
$link.rel = 'stylesheet'
$link.href = '//cdn.jsdelivr.net/npm/glightbox/dist/css/glightbox.min.css'
let $script = document.createElement('script')
$script.type = 'text/javascript'
$head.append($link)
$head.append($script)
$script.onload = () => {
  // images in gallery
  document.querySelectorAll('.ph_cont .ph a').forEach((a) => {
    a.className += ' glightbox'
  })

  // images in /photos
  if (location.pathname.match(/^\/photos\/$/)) {
    document.querySelectorAll('table[align=center] td a').forEach((a) => {
      a.className += ' glightbox'
    })
  }

  // add blank profile pic if missing in /profiles/:user
  if (location.pathname.match(/^\/profiles\/.+$/)) {
    let $td = document.querySelector('tbody tbody tr[valign=top] td')
    if ($td && $td.innerText == "") {
      let $b = document.querySelector('tbody tbody tr[valign=top] td+td font b')
      let name = $b.innerText
      $td.innerHTML = `<div class="photo"><a href="/photos/`+name+`"><img style="width:120px;" src="/images/icons/icon_60x60_chick.gif"/></a></div>`
    }
  }

  // images in /classifieds/*
  if (location.pathname.match(/^\/classifieds\/.+$/)) {
    document.querySelectorAll('table.outline a img').forEach(($img) => {
      $img.removeAttribute('onclick')
      $img.parentNode.className += ' glightbox'
    })
  }

  // add link to own profile when logged in
  let $b = document.querySelector("form[action='https://www.humaniplex.com/login.html'] td[align=center] b")
  if ($b) {
    let name = $b.innerText
    let profileLink = '<a href="/profiles/' + name + '">' + name + '</a>'
    $b.innerHTML = profileLink
  }

  // init lightbox
  let lightbox = GLightbox({})
}
$script.src = '//cdn.jsdelivr.net/gh/mcstudios/glightbox/dist/js/glightbox.min.js'