Copy questions on

Copies the current question to clipboard in quiz

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Copy questions on 
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Copies the current question to clipboard in quiz
// @author       Anonim Arı
// @match        https://ayva.itu.edu.tr/mod/quiz/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=edu.tr
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
  "use strict";

  document.addEventListener(
    "contextmenu",
    (e) => {
      e.returnValue = true;
      e.stopPropagation && e.stopPropagation();
    },
    true
  );

  function createButton() {
    const button = document.createElement("button");
    const art = `¯\\_(ツ)_/¯`;
    button.textContent = art;
    button.style = `
    bottom: 0px;
    right: 0px;
    position: fixed;
    color: white;
    z-index: 2147483647;
    padding: 10px;
    font-size: 25px;
    text-align: center;
    font-family: monospace;
    width: 200px;
    height: 253px;
    background-repeat: no-repeat;
    background-size: contain;

    background: black;
    `;
    return button;
  }

  const button = createButton();

  function chad(button) {
    button.style.backgroundImage =
      "url(https://media.tenor.com/MKpqR-aLLzYAAAAM/pov-you.gif)";
    button.innerText = "";
  }

  function clipboard(text) {
    const item = new ClipboardItem({
      "text/plain": new Blob([text], { type: "text/plain" }),
    });

    navigator.clipboard
      .write([item])
      .then(() => {
        chad(button);
        alert("Text copied to clipboard!");
      })
      .catch((error) => {
        alert("Error while copying! " + error);
      });
  }

  function copyContent() {
    const content = document.querySelector(
      'form > div > div > div[class="content"]'
    );
    if (!content) return alert("Eleman bulunamadi");
    clipboard(content.innerText);
  }

  button.addEventListener("click", function () {
    copyContent();
  });
  document.body.appendChild(button);
})();