This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/455186/1252079/WhiteSevsUtils.js
      
    使用文档
Utils.isNull(0);
结果:false
Utils.isNull("");
结果:false
Utils.isNull(" ");
结果:false
Utils.isNull(undefined);
结果:false
- Utils.assign代替- Object.assign
Utils.assign({1:1},{1:2,2:3})
结果:{1:2}
- Utils.waitNode等待元素出现在页面中,非使用- setInterval实现,性能损耗较少
/* 等待a元素出现,返回Promise对象,在then中或使用await获取结果,统一返回数组格式的元素,如[...a] */
Utils.waitNode("a").then((nodeList) => {
  console.log(nodeList.length);
});
/* 同时满足多个选择器的结果,都满足了才会触发回调 */
let moreDOM = await Utils.waitNode(["#page", "a[href]"]);
console.log(moreDOM);
- Utils.isVisible判断元素是否是可见的
- Utils.isPhone判断当前的- User-Agent是否是- 移动端
- Utils.toJSON代替- JSON.parse,满足更多格式的转换对象
Utils.toJSON("{123:123}");
结果:{123:123}
- Utils.Httpx代替油猴的- GM_xmlhttpRequest,统一管理请求状态
let httpx = new Utils.Httpx();
/* 修改配置 */
httpx.config({
  timeout: 5000,
  onabort: function () {
    console.log("请求取消");
  },
  ontimeout: function () {
    console.log("请求超时");
  },
  onerror: function (response) {
    console.log("httpx-onerror 请求异常");
    console.log(response);
  },
});
/* 发送post请求 */
let postResp = await httpx.post({
  url: url,
  data: JSON.stringify({
    test: 1,
  }),
});
- Utils.GM_Menu代替油猴的- GM_registerMenuCommand和- GM_unregisterMenuCommand,管理油猴菜单
let GM_Menu = new Utils.GM_Menu({
  menu_key: {
    text: "测试按钮",
    enable: true,
    showText: (text, enable) => {
      return "[" + (enable ? "√" : "×") + "]" + text;
    },
    callback: (key, status) => {
      console.log("点击菜单,值修改为", status);
    },
  },
});
/* 追加菜单按钮 */
GM_Menu.add({
    menu_key2: {
        text: "测试按钮2",
        callback: ()=>{
            console.log("点击 测试按钮2")
        }
    }
})
等...API请看代码