Skip to content

Instantly share code, notes, and snippets.

@data-doge
Last active August 29, 2015 14:26
Show Gist options
  • Save data-doge/a16a57beb13c7cda3126 to your computer and use it in GitHub Desktop.
Save data-doge/a16a57beb13c7cda3126 to your computer and use it in GitHub Desktop.
fun jQuery scripts, run on any site with jQuery
var diglettUrl = "https://fc06.deviantart.net/fs70/f/2010/165/9/4/050___Diglett_by_cammarin.png";
function initiateDiglettFuckdown () {
$('img').attr('src', diglettUrl);
$('a').text('DIGLETT');
$('*').each(function(i, element) {
var width = $(element).width();
$(element).css({
'backgroundImage' : 'url(' + diglettUrl + ')',
'backgroundSize' : width / 10
});
});
}
initiateDiglettFuckdown();
var deg = 0;
var $body = $('body');
var $elements = $('body *')
function rotate() {
requestAnimationFrame(rotate);
deg++;
$elements.css({
'-webkit-transform' : 'rotate(' + deg + 'deg)'
});
}
function initiateRotator () {
rotate();
}
initiateRotator();
var windowWidth = $(window).width();
var windowHeight = $(window).height();
function initiateScrambler () {
$(document).on('mousemove', function () {
scramble();
});
}
function scramble () {
$('body *').each(function (index, element) {
var position = randPosition();
$(element).css({
'position' : 'fixed',
'top' : position.y,
'left' : position.x
});
});
}
function randPosition () {
return {
x : Math.random() * windowWidth,
y : Math.random() * windowHeight
};
}
initiateScrambler();
var variance = 20;
var $body = $('body');
function initiateShaker () {
$body.css({
'position' : 'absolute'
});
shake();
}
function shake () {
requestAnimationFrame(shake);
var position = $body.position();
var currentX = position.left;
var currentY = position.top;
$body.css({
top : randCloseNumber(currentY, variance),
left : randCloseNumber(currentX, variance)
});
}
function randCloseNumber (number, range) {
var sign = Math.random() > 0.5 ? 1 : -1;
return sign * Math.random() * range + number;
}
initiateShaker();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment