debug

用于调试的脚本库

目前为 2017-11-11 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/34143/229636/debug.js

  1. // ==UserScript==
  2. // @name debug
  3. // @namespace https://github.com/yeomanye
  4. // @version 0.4
  5. // @include *://*
  6. // @description 用于调试的脚本库
  7. // @author Ming Ye
  8. // ==/UserScript==
  9.  
  10. // 开启调试
  11. var consoleFactory = function(prefix, type,suffix,debugMode) {
  12. prefix = prefix || "";
  13. type = type || "log";
  14. suffix = suffix || "";
  15. return function(msg){
  16. if (debugMode) {
  17. var arguments = Array.prototype.slice.apply(arguments);
  18. arguments.unshift(prefix);
  19. arguments.push(suffix);
  20. console[type].apply(null,arguments)
  21. // console[type](prefix, msg,suffix);
  22. }
  23. };
  24. };