Skip to content

Instantly share code, notes, and snippets.

@Kilian
Created January 6, 2011 15:04
Show Gist options
  • Save Kilian/767982 to your computer and use it in GitHub Desktop.
Save Kilian/767982 to your computer and use it in GitHub Desktop.
How to be an asshole
//make sure the browser window is 'maximised'
window.resizeTo(1024,768);
//no context menu
document.oncontextmenu = function(){return false}
//no loading in iframes
if (parent.frames.length > 0) top.location.replace(document.location);
//no dragging
document.ondragstart = function(){return false}
//no text selection, in IE
document.onselectstart=function(){
if (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password") {
return false
} else {
return true;
}
};
//no text selection, in Firefox
document.onmousedown=function(e){
var obj=e.target;
if (obj.tagName.toUpperCase() == "INPUT" || obj.tagName.toUpperCase() == "TEXTAREA" || obj.tagName.toUpperCase() == "PASSWORD") {
return true;
} else {
return false;
}
}
//prompt when the user leaves your page
window.onunload=function() {
function dontLeave() {
alert("Please come back!!1");
}
dontLeave();
}
//prevent user from copying or pasting text
window.onkeydown = function(e) {
if (e.ctrlKey == true) {
return false;
}
}
@betawaffle
Copy link

Dick move.

@YiGG
Copy link

YiGG commented May 23, 2011

I like :) Dont forget to show a hint that this site looks best in IE6 - and to be honest I miss the -tag and moving messages in the status bar..

@kirbysayshi
Copy link

Won't this throw an error with Annoying being undefined?

Or did I miss part of the joke...

@davidhellsing
Copy link

How about:

a.refresh = function() {
  setTimeout('location.reload(true);', 2000);
};  

@Kilian
Copy link
Author

Kilian commented May 29, 2011

I updated this with a bunch of new functions! Thanks for the replies/suggestions. This is still on my todo list:

  • bookmark alert
  • stuff floating around mouse
  • move messages in the status bar

@leobalter
Copy link

I made some fixes and jshinted the code! https://gist.github.com/998465

@Kilian
Copy link
Author

Kilian commented May 30, 2011

Thanks, I merged the changes back in! :)

@gmcouto
Copy link

gmcouto commented Jun 5, 2012

doesn't work on chrome, here

@gojun077
Copy link

Do you think that the 'a.stayOnSite = function ()' is still evil in the age of tabbed windows? Even sites like blogger give users the option of having links to pictures and other sites opened in a new window/tab...
-Jun

@rorysmyth
Copy link

doesn't work...how annoying :D

@alexmcmillan
Copy link

What is in s, and why do you throw away the text value in copyToClipboard() ?

https://gist.github.com/alexmcmillan/4419e9375aec9886a919beac02bc5e9a

@AlexNodex
Copy link

Opening links in a popup - it would be easier to assign target="_blank" than to create a popup ;)

@joe-mojo
Copy link

A "force video autoplay" and a "recurrent pop-in" feature are missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment