OnlyFakes easy prompt copy

Simply click on the images to copy the prompt

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name            OnlyFakes easy prompt copy
// @namespace       Violentmonkey Scripts
// @match           https://uncensoredai.io/*
// @grant           none
// @version         0.1.1
// @author          vipprograms
// @description     Simply click on the images to copy the prompt
// @grant           GM_addStyle
// ==/UserScript==
GM_addStyle(`
:root{
  --offwhite:color: hsl(0, 0%, 98%);
}
p{  white-space: pre;}

.oepc_popup{position:absolute; top:0; left:0; transform:translate(-50%,-50%); padding:10px 20px; background-color:hsla(0,0%,0%,70%);
  color:var(--offwhite); border-radius:5px; z-index:1000; backdrop-filter:blur(20px);
}
`);

const showPopup = (text) => {
  const popup = document.createElement('div');
  popup.innerHTML = `<div class="oepc_popup">${text}</div>`;
  document.body.appendChild(popup);

  // Get the current mouse position
  const mouseX = window.innerWidth / 2;
  const mouseY = window.innerHeight / 2;

  // Set the position of the popup immediately
  const scrollY = window.scrollY;
  popup.firstChild.style.position = 'absolute';
  popup.firstChild.style.left = `${mouseX}px`;
  popup.firstChild.style.top = `${mouseY + scrollY}px`;

  setTimeout(() => {
    const innerDiv = popup.firstChild;
    innerDiv.style.transition = 'opacity 0.5s';
    innerDiv.style.opacity = '0';
    setTimeout(() => {
      popup.remove();
    }, 600);
  }, 1000);
};



const copyPrompt = async (prompt) => {
  await navigator.clipboard.writeText(prompt);
};

const processImages = () => {
  document.querySelectorAll('img[alt^="Image made with A"]:not([data-listener-added])').forEach(img => {
    img.setAttribute('data-listener-added', 'true');
    img.addEventListener('click', () => {
      const prompt = img.alt.split('Prompt: ')[1];
      if (!prompt) return;
      copyPrompt(prompt);

      let text = `Copied!<br><br>Prompt:<br>${prompt}`;

      showPopup(text);

    });
  });
};

document.addEventListener('DOMContentLoaded', processImages);
window.addEventListener('scroll', processImages);