CopyID stashdb.org

22/4/2024, 10:48:29 pm

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        CopyID stashdb.org
// @namespace   Violentmonkey Scripts
// @match       https://stashdb.org/scenes/*
// @grant       none
// @version     1.0
// @author      nimmadev
// @license MIT
// @description 22/4/2024, 10:48:29 pm
// ==/UserScript==

window.addEventListener('load', () => {
  setTimeout(() => {
    const script = document.createElement('script');
    script.text = `function copyPageUrl() {
      const pageUrl = window.location.href;
      const parts = pageUrl.split('/');
      const lastPart = parts[parts.length - 1];
      navigator.clipboard.writeText(lastPart)
        .then(() => {
          console.log('Page URL copied:', pageUrl);
          alert('ID Copied')
        })
        .catch(err => {
          console.error('Failed to copy URL:', err);
        });
    }`
    document.body.appendChild(script);
    const titleName = document.querySelector('.scene-info > div:first-child > h3:nth-child(2)');
    titleName.style.display = 'flex'
    titleName.style.alignItems = 'center'
    titleName.innerHTML += `
      <span style="margin-left:auto; display:flex; align-items:center; color:#3498db; cursor:pointer;" onclick="copyPageUrl()">
        Copy Id
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-left:5px;">
          <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
          <path d="M5 15h8"></path>
        </svg>
      </span>`;
  }, 1000);
});