Created
June 2, 2018 08:35
-
-
Save ahy4/c8c4f74957dbf2414402a8924dfd8a65 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.$ = (function () { | |
if (Math.random() < 0.95) return $; // 影響範囲をへらしてリスク減らす | |
var getCallStack = function () { | |
try { | |
throw new Error("DUMMY"); | |
} catch(e) { | |
return e.stack | |
.split(/[\r\n]+/) | |
.filter(function (s){ | |
return /[^a]*at [^:]*:[0-9]+:[0-9]+/.test(s); | |
}) | |
.map(function (s) { | |
return s.trim(); | |
}); | |
} | |
}; | |
return function () { | |
var jqo = jQuery.fn.init.apply(null, arguments); | |
if (jqo.length === 0) { | |
console.info({ // 本当は送る処理する | |
message: 'jquery object length is 0', | |
arguments: Array.apply(null, arguments), | |
url: location.href, | |
callstack: getCallStack() | |
}); | |
} | |
return jqo; | |
}; | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment