调试文件优化

优化Quicker原版调试文件体验

目前为 2022-03-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         调试文件优化
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  优化Quicker原版调试文件体验
// @author       Cesaryuan
// @match        file:///*/quicker_*_log.htm
// @require      http://code.jquery.com/jquery-2.2.4.min.js
// @require      http://code.jquery.com/color/jquery.color-2.1.2.min.js
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  "use strict";
  // queryByXpath
  function queryByXpath(xpath, root) {
    var xpathResult = document.evaluate(
      xpath,
      root || document,
      null,
      XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
      null
    );
    var result = [];
    for (var i = 0, len = xpathResult.snapshotLength; i < len; ++i) {
      result.push(xpathResult.snapshotItem(i));
    }
    return result;
  }
  for (const stepHeader of queryByXpath(
    "//div[@class='step-header' and ../div[@class='step-content']/div[@title and contains(@class, 'message') and contains(text(), '已禁用')]]"
  )) {
    // add class quicker-forbid and quicker-light
    stepHeader.classList.add("quicker-forbid");
    stepHeader.classList.add("quicker-light");
  }

  for (const stepHeader of queryByXpath(
    "//div[@class='step-header' and ../div[@class='step-content']/div[@title and contains(@class, 'message') and contains(text(), '不符合条件,跳过。')]]"
  )) {
    // add class quicker-forbid
    stepHeader.classList.add("quicker-skiped-if");
    stepHeader.classList.add("quicker-light");
  }

  $("div.message-warning:contains(出错)")
    .parents(".step-content")
    .prev(".step-header")
    .addClass("quicker-warn-step");
  $("div.sys_stop:contains(标记为出错:1)")
    .parents(".step-content")
    .prev(".step-header")
    .addClass("quicker-warn-step");

  //inject css text
  var css = `
  .quicker-warn-step {
    background-color: #ffd6d6 !important;
  }
  .quicker-light {
    background-color: #f8f8f8 !important;
  }
  .quicker-forbid::before {
      content: '已禁用';
      color: #a0a0a0
  }
  .quicker-skiped-if::before {
      content: '不符合条件';
      color: #a0a0a0
  }
  .quicker-skiped-if *, .quicker-forbid *  {
      /* text-decoration: line-through 0.01em; */
  }
          `;
  var style = document.createElement("style");
  style.type = "text/css";
  style.appendChild(document.createTextNode(css));
  document.head.appendChild(style);
})();