用于调试的脚本库
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/34143/230834/debug.js
// ==UserScript==
// @name debug
// @namespace https://github.com/yeomanye
// @version 0.5.3
// @include *://*
// @description 用于调试的脚本库
// @author Ming Ye
// ==/UserScript==
(function(context) {
// 开启调试
var consoleFactory = function(prefix, type, suffix, debugMode) {
prefix = prefix || "";
type = type || "log";
suffix = suffix || "";
return function(msg) {
if (debugMode) {
var arguments = Array.prototype.slice.apply(arguments);
arguments.unshift(prefix);
arguments.push(suffix);
console[type].apply(null, arguments);
}
};
};
// 当参数为true时开启调试
var debugTrue = function(isDebugger) {
return function() {
if (isDebugger) debugger;
}
}
context.myDebugger = {
consoleFactory: consoleFactory,
debugTrue: debugTrue
};
})(window);