我正在编写一个GreaseMonkey脚本,它可以抓取cookie并将其复制到剪贴板上。它正确地抓取了cookie,但没有将其复制到我的剪贴板上。
// ==UserScript==
// @name The OW Helper
// @namespace You
// @version 1.0
// @include *.outwar.com/*
// @exclude *.outwar.com/myaccount*
// @require http://code.jquery.com/jquery-latest.js
// @grant GM_setClipboard
// ==/UserScript==
var sessid = document.cookie.split('rg_sess_id=')[1].split(';')[0];
var btn1 = document.createElement("button");
btn1.appendChild(document.createTextNode("COPY RG_SESS_ID"));
btn1.setAttribute('title', sessid);
btn1.setAttribute('style', 'font-family: "Verdana" !important; background-color: inherit; width:160px; padding:4px; margin-bottom: 1px; color: #FFF !important; font-weight:bold !important; border:1px; cursor: pointer;');
btn1.addEventListener('mouseover', function() {
this.title = sessid
}, false);
btn1.addEventListener("click", function() {
GM_setClipboard(sessid, "text")
}, false);
$("div#accordian ul li").last().append("<li><hr color=#C50202></li>");
$("div#accordian ul li").last().append(btn1);
$("div#accordian ul li").last().append("<li><hr color=#C50202></li>");
这里我漏掉了什么?我搜索了其他帖子,但似乎没有这个问题,我似乎找不到任何我没有包括的东西。
发布于 2021-02-03 14:22:28
如果您使用的是GM4 (例如,当前的GreaseMonkey),则不支持GM_setClipboard
,您应该使用GM.setClipboard。
https://stackoverflow.com/questions/66019285
复制相似问题