Copy Mturk ID to Clipboard Button

Adds a copy to clipboard button in the upper right corner of the page

当前为 2023-05-25 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Copy Mturk ID to Clipboard Button
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds a copy to clipboard button in the upper right corner of the page
// @match        *://*/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Create the button element
    let copyButton = document.createElement('button');
    copyButton.innerHTML = 'Mturk';
    copyButton.style.position = 'fixed';
    copyButton.style.top = '45px';
    copyButton.style.right = '10px';
    copyButton.style.zIndex = '9999';
    copyButton.style.borderRadius = '50%';
    copyButton.style.backgroundColor = 'red';
    copyButton.style.width = '30px';
    copyButton.style.height = '30px';

    // Add hover effect
    copyButton.onmouseover = function() {
        this.style.width = 'auto';
        this.style.height = 'auto';
        this.style.borderRadius = '5px';
        this.style.padding = '5px 10px';
    }
    copyButton.onmouseout = function() {
        this.style.width = '30px';
        this.style.height = '30px';
        this.style.borderRadius = '50%';
        this.style.padding = '0px';
    }

    // Add click event to copy text to clipboard
    copyButton.onclick = function() {
        navigator.clipboard.writeText('A4T4577P6JL6R');
    }

    // Append the button to the body
    document.body.appendChild(copyButton);
})();