PORNBOX Better List Models Names and Copy button (with IA Help) v.3.00

Reformat the Models list with an space after each comma and correction for easy copy (IA)

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         PORNBOX Better List Models Names and Copy button (with IA Help) v.3.00
// @namespace    http://tampermonkey.net/
// @version      3.00
// @description  Reformat the Models list with an space after each comma and correction for easy copy (IA)
// @author       Janvier57
// @icon         https://external-content.duckduckgo.com/ip3/www.pornbox.com.ico
// @match        https://pornbox.com/application/model/*
// @match        https://www.pornbox.com/application/model/*
// @exclude      https://pornbox.com/application/model/list
// @exclude      https://www.pornbox.com/application/model/list
// @match        https://pornbox.com/*
// @match        https://www.pornbox.com/*
// @grant        none
// ==/UserScript==

(function() {
      'use strict';
      console.log('Script started');
      var modelsList = null;
      var timeout = 1000; // 1 second
      var interval = 100; // 100ms

      function waitForElement() {
        modelsList = document.querySelector('.model-info__value.model-info__joint-models.more-less--hidden');
        if (modelsList) {
          console.log('modelsList found');
          runScript();
        } else {
          console.log('modelsList not found, waiting...');
          setTimeout(waitForElement, interval);
          timeout -= interval;
          if (timeout <= 0) {
            console.log('Timeout exceeded, aborting script');
          }
        }
      }

      function runScript() {
        var relatedModels = document.querySelectorAll('.model-info__value.model-info__joint-models.more-less--hidden .model-info__tag');
        console.log('relatedModels:', relatedModels);

        // Remove :after pseudo-element
        var stylesheet = document.createElement('style');
        stylesheet.innerHTML = '.model-info__tag:after { content: "" !important; margin-right: 0px !important; }';
        document.head.appendChild(stylesheet);
        console.log('Stylesheet added');

        // Add comma + space after each model name
        var modelsText = '';
        relatedModels.forEach((model, index) => {
          modelsText += model.outerHTML;
          if (index < relatedModels.length - 1) {
            modelsText += ', ';
          }
        });
        console.log('modelsText:', modelsText);
        modelsList.innerHTML = modelsText;
        console.log('modelsList updated');

        // Add "Copy Related Models" button
        var copyButton = document.createElement('button');
        copyButton.textContent = 'Copy Related Models';
        copyButton.onclick = function() {
          var modelsText = '';
          relatedModels.forEach((model, index) => {
            modelsText += model.textContent;
            if (index < relatedModels.length - 1) {
              modelsText += ', ';
            }
          });
          console.log('Copy button clicked');
          navigator.clipboard.writeText(modelsText).then(function() {
            alert('Copied');
          });
        };
        modelsList.parentNode.appendChild(copyButton);
        console.log('Copy button added');

        // Add "Copy Related Models with Links" button
        var modelsLinksText = '';
        relatedModels.forEach((model, index) => {
          modelsLinksText += '<a href="' + model.href + '">' + model.textContent + '</a><br>';
        });
        var copyLinksButton = document.createElement('button');
        copyLinksButton.textContent = 'Copy Related Models with Links';
        copyLinksButton.onclick = function() {
          console.log('Copy links button clicked');
          navigator.clipboard.writeText(modelsLinksText).then(function() {
            alert('Copied');
          });
        };
        modelsList.parentNode.appendChild(copyLinksButton);
        console.log('Copy links button added');
      }

      waitForElement();
    })();