Comparing version 0.0.2 to 1.0.0
113
fyu.js
@@ -1,6 +0,113 @@ | ||
async function shiftHorizontalRandom( { //Shifts each element to the left or right by 25 pixels | ||
var elems = document.body.getElementsByTagName("*"); | ||
function sleep(ms) { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} | ||
function getRandomInt(min, max) { | ||
min = Math.ceil(min); | ||
max = Math.floor(max); | ||
return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive | ||
} | ||
async function shiftHorizontalRandom() { // Shifts each element randomly left or right 4 times per second | ||
var elems = Array.from(document.body.getElementsByTagName("*")); | ||
while (true) { | ||
for (elem in elems) { | ||
elems[elem].style.transform = "none"; | ||
elems[elem].style.transform = `translateX(${getRandomInt(-200, 100)}px)`; | ||
}; | ||
await sleep(250); | ||
}; | ||
}; | ||
async function shiftVerticalRandom() { // Shifts each element randomly up or down 4 times per second | ||
var elems = Array.from(document.body.getElementsByTagName("*")); | ||
while (true) { | ||
for (elem in elems) { | ||
elems[elem].style.transform = "none"; | ||
elems[elem].style.transform = `translateY(${getRandomInt(-200, 100)}px)`; | ||
}; | ||
await sleep(250); | ||
}; | ||
}; | ||
async function shiftRandom() { // Shifts each element randomly around the screen 4 times per second | ||
shiftHorizontalRandom(); | ||
shiftVerticalRandom(); | ||
}; | ||
async function rotateRandom() { // Rotates each element randomly 4 times per second | ||
var elems = Array.from(document.body.getElementsByTagName("*")); | ||
while (true) { | ||
for (elem in elems) { | ||
elems[elem].style.transform = `rotate(${getRandomInt(0, 359)}deg)`; | ||
}; | ||
await sleep(250); | ||
}; | ||
}; | ||
async function runAway() { // Makes every element "run away" from the cursor when hovered over | ||
var elems = Array.from(document.body.getElementsByTagName("*")); | ||
for (elem in elems) { | ||
elem.style.transform = `translateX(${Math.floor(Math.random() * 10) + 1}px)`; | ||
elems[elem].addEventListener('mouseover', moveFromMouse); | ||
}; | ||
while (true) { | ||
await sleep(250); | ||
}; | ||
}; | ||
async function moveFromMouse(e) { // The actual funtion run by runAway() | ||
e.target.style.transform = "none"; | ||
e.target.style.transform = `translate(${getRandomInt(-100, 50)}px, ${getRandomInt(-100, 50)}px)`; | ||
} | ||
async function colorsRandom() { // Changes every element's color and background color every 2.5 seconds | ||
var elems = Array.from(document.body.getElementsByTagName("*")); | ||
while (true) { | ||
for (elem in elems) { | ||
let currentBack = elems[elem].style.backgroundColor; | ||
let currentColor = elems[elem].style.color; | ||
elems[elem].animate([ | ||
// keyframes ${getRandomInt(0, 256)} | ||
{ backgroundColor: currentBack, color: currentColor }, | ||
{ backgroundColor: `rgb(${getRandomInt(0, 256)},${getRandomInt(0, 256)},${getRandomInt(0, 256)})`, color: `rgb(${getRandomInt(0, 256)},${getRandomInt(0, 256)},${getRandomInt(0, 256)})` },{ backgroundColor: currentBack, color: currentColor } | ||
], { | ||
// timing options | ||
duration: 2500, | ||
easing: 'ease-in-out', | ||
iterations: 1 | ||
}); | ||
}; | ||
await sleep(2500); | ||
}; | ||
}; | ||
async function opacityRandom() { // Changes every element's opacity every 5 seconds | ||
var elems = Array.from(document.body.getElementsByTagName("*")); | ||
while (true) { | ||
for (elem in elems) { | ||
let opacity = Math.random() * 2; // yes i know this is out of range just shut up i want things to be more opaque than not more often | ||
if (elems[elem].classList.contains("dontNuke")) { | ||
opacity = 1; | ||
} | ||
elems[elem].animate([ | ||
// keyframes | ||
{ opacity: 1 }, | ||
{ opacity: opacity }, | ||
{ opacity: 1 } | ||
], { | ||
// timing options | ||
duration: 5000, | ||
easing: 'ease-in-out', | ||
iterations: 1 | ||
}); | ||
}; | ||
await sleep(5000); | ||
}; | ||
}; | ||
async function makeItHell() { | ||
shiftRandom(); | ||
runAway(); | ||
colorsRandom(); | ||
opacityRandom(); | ||
}; |
{ | ||
"name": "fyu", | ||
"version": "0.0.2", | ||
"version": "1.0.0", | ||
"description": "Do your users take your website for granted? Do want to make them using your website living hell? Look no further, F.Y.U. is here!", | ||
@@ -5,0 +5,0 @@ "main": "fyu.js", |
# FYU | ||
Do your users take your website for granted? Do want to make them using your website living hell? Look no further, F.Y.U. is here! Oh yeah, FYU stands for something 👀. | ||
(PS you might recognize my name from my [url lengthener](https://ax56.pro) which went viral a few weeks back) | ||
## Getting the script | ||
Getting the script is super easy, as it is hosted with jsdelivr (seriously that site is awesome!). All you need to do is put this into your | ||
Getting the script is super easy, as it is hosted with jsDelivr (seriously that site is awesome!). All you need to do is put this at the end of the `body` of your site: | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/fyu@latest/fyu.js"></script> | ||
``` | ||
## Activating the Script | ||
Actually using the script is really easy, but you might not want to use every function, so here's a litte guide: | ||
- `makeithell()` - You have no care for the world. Every knob at the max. | ||
- `shiftHorizontalRandom()` - Shifts each element randomly left or right 4 times per second | ||
- `shiftVerticalRandom()` - Shifts each element randomly up or down 4 times per second | ||
- `shiftRandom()` - Does both `shiftHorizontalRandom()` and `shiftHorizontalRandom` at once | ||
- `rotateRandom()` - Rotates each element randomly 4 times per second. Highly unreccomended as it can interfere with the shifting functions and just look exceptionally displeasing on it's own. | ||
- `runAway()` - Makes every element "run away" from the cursor when hovered over | ||
- `colorsRandom()` - Changes every element's color and background color every 2.5 seconds | ||
- `opacityRandom()` - Changes every element's opacity every 5 seconds | ||
## Selecting Certain Elements | ||
Now, lets say you want some elements to stay unchanged, like if you have a div which pretty much contains the entire site. All you need to do is add the `dontNuke` class to those HTML elements. For example, here is a `<p>` which would be affected and one which wouldn't: | ||
Affected: | ||
```html | ||
<p>Hello there! uwu</p> | ||
``` | ||
Not Affected: | ||
```html | ||
<p class="dontNuke">Hello there! uwu</p> | ||
``` | ||
## Contributing | ||
If you would like to add your own nuking functions to this script, simply make a pr with the ***asyncronous*** function added to `fyu.js` and the call to the said function inside of `makeItHell()`. Don't worry about minifying `fyu.js`, as jsDelivr does that for us. If the function(s) you add aren't asyncronous, I'll comment on your pr to make the change. The reason we want to do this is to not interfere with any other scripts or functions within this script. |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
41003
103
2
38
0