coursepoint OMN

helps study for tests

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

Advertisement:

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

Advertisement:

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         coursepoint OMN
// @description  helps study for tests
// @version      1.3
// @match        https://qp-examengine.hlrptech.com/*
// @grant        GM_setClipboard
// @namespace https://greasyfork.org/users/1617665
// ==/UserScript==

let questionMap = {};
let currentSequence = 1;

const origOpen = XMLHttpRequest.prototype.open;
const origSend = XMLHttpRequest.prototype.send;

XMLHttpRequest.prototype.open = function(method, url) {
  this._url = url;
  return origOpen.apply(this, arguments);
};

XMLHttpRequest.prototype.send = function() {
  this.addEventListener('load', function() {
    if (!this._url) return;
    try {
      const data = JSON.parse(this.responseText);
      if (!data?.promptText) return;

      const seq = data.sequence;
      const q = data.promptText;
      const c = data.choiceInteraction.simpleChoices.map(x => x.label);

      questionMap[seq] = { q, c };

      // First question — set current to 1
      if (!this._url.match(/\/items\/\d+/)) {
        currentSequence = 1;
      }

      btn.innerText = 'Copy Question';
      btn.style.background = '#fff';
    } catch(e) {}
  });
  return origSend.apply(this, arguments);
};

const btn = document.createElement('button');
btn.innerText = 'Copy Question';
btn.style.cssText = 'position:fixed;top:10px;right:10px;z-index:9999;padding:8px 12px;background:#fff;color:#111;border:1px solid #ccc;border-radius:4px;cursor:pointer;font-size:14px;';

btn.addEventListener('mouseenter', () => { btn.style.background = '#eee'; });
btn.addEventListener('mouseleave', () => { if (btn.innerText !== 'Copied!') btn.style.background = '#fff'; });

btn.addEventListener('click', () => {
  const entry = questionMap[currentSequence];
  if (entry) {
    GM_setClipboard(entry.q + '\n\n' + entry.c.join('\n'));
    btn.innerText = 'Copied!';
    btn.style.background = '#eee';
    if (questionMap[currentSequence + 1]) {
      currentSequence++;
      btn.innerText = 'Copy Question';
      btn.style.background = '#fff';
    }
  }
});

document.body.appendChild(btn);