Greasy Fork is available in English.

解锁英语真题在线功能

解除翻译次数和显示加速读音

// ==UserScript==
// @name         解锁英语真题在线功能
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  解除翻译次数和显示加速读音
// @author       TanHaX
// @match        *://zhenti.burningvocabulary.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    // 添加点击事件监听器
    document.addEventListener('click', function() {
        // 执行localStorage.removeItem('extra_data')
        localStorage.removeItem('extra_data');
    });
})();

(function() {
  // 要修改的 XPath 节点
  const xpath = '/html/body/div[2]/div[4]/div[1]/div/div[2]';

  // 要修改的属性名
  const attributeName = 'aria-hidden';

  // 获取要修改的节点
  const node = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

  // 初始状态为 false
  let attributeValue = 'false';

  // 修改属性值函数
  function toggleAttributeValue() {
    attributeValue = (attributeValue === 'false') ? 'true' : 'false';
    node.setAttribute(attributeName, attributeValue);
  }

  // 创建 MutationObserver 实例
  const observer = new MutationObserver((mutations) => {
    for (const mutation of mutations) {
      if (mutation.type === 'attributes' && mutation.attributeName === attributeName) {
        // 属性值被改回 true,重新改为 false
        if (node.getAttribute(attributeName) !== attributeValue) {
          node.setAttribute(attributeName, attributeValue);
        }
      }
    }
  });

  // 启动 MutationObserver
  observer.observe(node, { attributes: true });

  // 创建开关按钮
  const toggleButton = document.createElement('button');
  toggleButton.textContent = '读音速度开关';
  toggleButton.style.position = 'fixed';
  toggleButton.style.top = '50px';
  toggleButton.style.right = '50px';
  toggleButton.addEventListener('click', toggleAttributeValue);

  // 添加按钮到页面
  document.body.appendChild(toggleButton);
})();