激战2维基辅助 一键复制API ID

在激战2维基百科上,一键复制技能、特性和物品等的 ID 代码

目前为 2020-10-16 提交的版本。查看 最新版本

// ==UserScript==
// @name              激战2维基辅助 一键复制API ID
// @name:en           API ID copy tool on wiki.guildwars2.com
// @namespace         https://gf.qytechs.cn/zh-CN/scripts/406297-%E6%97%85%E6%B3%95%E5%B8%88%E8%90%A5%E5%9C%B0-%E4%B8%87%E6%99%BA%E7%89%8C%E5%8A%A9%E6%89%8B-%E4%B8%AD%E8%8B%B1%E8%BD%AC%E6%8D%A2-%E9%80%A0%E4%BB%B7%E5%88%86%E6%9E%90-%E6%A0%B7%E5%BC%8F%E8%87%AA%E5%AE%9A%E4%B9%89
// @version           0.1
// @description       在激战2维基百科上,一键复制技能、特性和物品等的 ID 代码
// @description:en    add a button to copy API ID code of items, skills, traits on wiki.guildwars2.com
// @icon              https://wiki.guildwars2.com/favicon.ico
// @author            Saber Lily 莉莉哩哩 Gay哩Gay气
// @run-at            document-end
// @require           https://unpkg.com/jquery@3/dist/jquery.min.js
// @match             https://wiki.guildwars2.com/wiki/*

// @grant        none
// @license      GPL-v3
// ==/UserScript==

/* global $ */

// 作者简介
// Saber Lily.1960 Current in WSR EU Server
// 莉莉哩哩 Gay哩Gay气,一个天天划水的休闲 激战2 欧服玩家。
// 如果你觉得该脚本对你有所帮助,欢迎赞助我!

// 如有 Bug 请在 gf.qytechs.cn 我的脚本评论区进行反馈。
// 私人脚本可联系我付费定制,QQ:610915518

// 版权申明
// 本脚本为 Saber Lily.1960 原创,未经作者授权禁止转载,禁止转载范围包括但不仅限于:贴吧、NGA论坛等。

$('a[rel="nofollow"][class="external text"]').each(function(){
    if ($(this).attr("href") && $(this).attr("href").startsWith("https://api.guildwars2.com/v2") ) {
        var iidd = $(this).attr("href").toString().split("ids=", 2)[1].split("&", 2)[0];
        var html = ' <button type="button" onclick="copyToClipboard('.concat(iidd, ')">Copy ', iidd, '</button>') ;
        $(this).after(html);
    };
});

var ctc = `<script>
function copyToClipboard(text) {
    if (window.clipboardData && window.clipboardData.setData) {
        // Internet Explorer-specific code path to prevent textarea being shown while dialog is visible.
        return clipboardData.setData("Text", text);

    }
    else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
        var textarea = document.createElement("textarea");
        textarea.textContent = text;
        textarea.style.position = "fixed";  // Prevent scrolling to bottom of page in Microsoft Edge.
        document.body.appendChild(textarea);
        textarea.select();
        try {
            return document.execCommand("copy");  // Security exception may be thrown by some browsers.
        }
        catch (ex) {
            console.warn("Copy to clipboard failed.", ex);
            return false;
        }
        finally {
            document.body.removeChild(textarea);
        }
    }
}
</script>`

$('#globalWrapper').after(ctc);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址