Greasy Fork 还支持 简体中文。

Listography Easy Copy Permalink

Adds a button to copy list permalinks to clipboard

目前為 2023-12-29 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Listography Easy Copy Permalink
// @description Adds a button to copy list permalinks to clipboard
// @version     1.0.0
// @author      petracoding
// @namespace   petracoding
// @grant       none
// @include     https://listography.com/*
// @include     http://listography.com/*
// ==/UserScript==

// Early Return
if (!document.querySelector(".about")) return;

// Get User Id from avatar image
const userId = document.querySelector(".about img").getAttribute("src").replace("/action/user-image?uid=", "");

// Get all listboxes and add buttons
const listboxes = document.querySelectorAll(".listbox");
[...listboxes].forEach(listbox => {
  const listId = listbox.getAttribute("id").replace("listbox-", "");
  const permalink = "https://listography.com/action/list?uid=" + userId + "&lid=" + listId;
  
  const datesEl = listbox.querySelector(".dates");
  const copyBtn = document.createElement("button");
  
  copyBtn.innerHTML = "copy link";
  copyBtn.setAttribute("class", "copy-permalink-btn");
  copyBtn.setAttribute("title", permalink);
  copyBtn.setAttribute("style", `
		background: none;
    border: none;
    font-size: 1em;
    color: inherit;
    font-weight: bold;
    display: block;
    padding: 0;
    cursor: pointer;
	`);
  datesEl.appendChild(copyBtn);
});

// Add event listeners to the new buttons
const btns = document.querySelectorAll(".copy-permalink-btn");
[...btns].forEach(btn => {
  btn.addEventListener("click", () => {
    navigator.clipboard.writeText(btn.getAttribute("title"));
    btn.innerHTML = "copied!";
    
    setTimeout(function(){
    	btn.innerHTML = "copy link";
    }, 1000);
  });
});