NitasToolBox

NitaToolBox浏览器插件

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name     NitasToolBox
// @version  2.0
// @namespace NitasToolBox_plugin
// @match https://www.wolai.com/*
// @description NitaToolBox浏览器插件
// @author Nita
// ==/UserScript==

(

function() {
    'use strict';
    var todoid = "((id#8tiTnAkCi7Pi3sPPovYnMr))";
    var Importantid = "((id#3NHZ84Ak5LX94DjMQFdmWr))";

    document.onkeydown = function (e)
    {
        e = e || window.event; //标准化事件对象
        var obj = e.srcElement;
        console.log("进入"+e.keyCode);
        console.log("altKey"+ e.altKey);

        if (e.keyCode == 113 ) {
            setCopyVaule(todoid);
        }
        if (e.altKey && e.keyCode == 49 ) {
            setCopyVaule(Importantid);
        }
    }
   function setCopyVaule(value,str)
    {
        debugger;
        const input = document.createElement('input');
        document.body.appendChild(input);input.setAttribute('readonly', 'readonly');
        input.setAttribute('value',value);
        document.body.appendChild(input);
        input.setSelectionRange(0, 9999);
        input.select();
        if (document.execCommand('copy')) {
            document.execCommand('copy');
            console.log('复制成功');
        }
         debugger;
         //window.clipboardData.setData("Text", str);//设置数据
        document.body.removeChild(input);
    }
  function fireKeyEvent(el, evtType, keyCode) {
   debugger;
  var evtObj;
  if (document.createEvent) {
      if (window.KeyEvent) {//firefox 浏览器下模拟事件
          evtObj = document.createEvent('KeyEvents');
          evtObj.initKeyEvent(evtType, true, true, window, true, false, false, false, keyCode, 0);
      } else {//chrome 浏览器下模拟事件
          //evtObj = document.createEvent('UIEvents');
           evtObj = new UIEvent(evtType);

          delete evtObj.keyCode;
          if (typeof evtObj.keyCode === "undefined") {//为了模拟keycode
               console.log('keyCode'+keyCode);
              Object.defineProperty(evtObj, "keyCode", { value: keyCode });
          } else {
              evtObj.key = String.fromCharCode(keyCode);
          }

          if (typeof evtObj.ctrlKey === 'undefined') {//为了模拟ctrl键
              Object.defineProperty(evtObj, "ctrlKey", { value: true });
               console.log('ctrlKey'+ true);
          } else {
              evtObj.ctrlKey = true;
          }
      }
      el.dispatchEvent(evtObj);

  } else if (document.createEventObject) {//IE 浏览器下模拟事件
      evtObj = document.createEventObject();
      evtObj.keyCode = keyCode
      el.fireEvent('on' + evtType, evtObj);
  }
}
}
)();