Revisions
-
Kilian revised this gist
Jun 1, 2011 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -174,6 +174,15 @@ clipboardData.setData('text', s); } }; /** * prevent the user from using the back button */ a.preventBack = function () { try { history.forward(); setTimeout('preventBack()', 500); } catch (e) {} }; /** * Execute all the annoying.js functions */ @@ -192,6 +201,7 @@ this.stayOnSite(); this.addCopyright(); //useless with the noCopy(); function! this.copyToClipboard(); this.preventBack(); }; }(Annoying)); -
Kilian renamed this gist
May 30, 2011 . 1 changed file with 39 additions and 35 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,7 @@ * Licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php * */ /*jshint forin: false, immed: true, curly: true, eqeqeq: true, bitwise: true, noempty: true */ (function(a) { /** * Resize the window to fullscreen (1024x768 always) @@ -19,39 +20,39 @@ window.resizeTo(1024,768); }; /** * Always keep the browser full screen */ a.keepFullScreen = function () { window.onresize = function() { window.resizeTo(1024, 768); }; }; /** * Disable right click so users can not copy! */ a.noRightClick = function () { document.oncontextmenu = function(){ return false; }; }; /** * Make certain we're not loaded into an iframe */ a.onTop = function () { if (parent.frames.length > 0) { top.location.replace(document.location); } }; /** * Disable users dragging photos or text to they can't copy them */ a.noDrag = function () { document.ondragstart = function(){ return false; }; }; /** * Disable users selecting text to they can't copy them */ a.noSelect = function () { //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; } @@ -64,7 +65,7 @@ } else { return false; } }; }; /** * Most users accidentally close the web page. Remind them of this. @@ -77,100 +78,102 @@ alert(message); } dontLeave(); }; }; /** * Disable users copying text via shortcuts */ a.noCopy = function () { window.onkeydown = function(e) { if ( e.ctrlKey ) { return false; } }; }; /** * Refresh the page every minute so it stays up to date */ a.keepUpToDate = function(){ setTimeout( function(){window.location = window.location;}, 1000*60 ); }; /** * suppress all error messages so we never have any */ a.neverAnyBugs = function () { window.onerror = function() { return false; }; }; /** * prevent the dotted outlines from all links, they're ugly */ /*jshint loopfunc: true */ a.preventOutlines = function () { for(var i in (a = document.getElementsByTagName('a'))) { a[i].onmousedown = function() { this.blur(); // most browsers this.hideFocus = true; // ie this.style.outline = 'none'; // mozilla }; a[i].onmouseout = a[i].onmouseup = function() { this.blur(); // most browsers this.hideFocus = false; // ie this.style.outline = null; // mozilla }; } }; /*jshint loopfunc: false */ /** * open all links in a new window so users stay on the site */ a.stayOnSite = function () { for(var i in (a = document.getElementsByTagName('a')) ) { a[i].href = "javascript:window.open('" + a[i].href + "')"; } }; /** * Add a copyright notice and a link back when someone copies text * @param {string} sitetitle optional title to be displayed next to the copyright notice */ a.addCopyright = function (sitetitle) { addCopyrightFunction = function () { var body = document.getElementsByTagName('body')[0], selection = window.getSelection(), copyright = sitetitle || "annoying.js", pagelink = "<br />Read more at: <a href='"+document.location.href+"'>"+document.location.href+"</a><br />Copyright ©" + copyright, newdiv = document.createElement('div'); newdiv.style.position='absolute'; newdiv.style.left='-99999px'; body.appendChild(newdiv); newdiv.innerHTML = selection + pagelink; selection.selectAllChildren(newdiv); window.setTimeout(function() { body_element.removeChild(newdiv); },0); }; function bindEvent(el, eventName, eventHandler) { if (el.addEventListener){ el.addEventListener(eventName, eventHandler, false); } else if (el.attachEvent){ el.attachEvent('on'+eventName, eventHandler); } } bindEvent(document, 'copy', function () { addCopyrightFunction(); }); }; /* * Copy the current url or a message to the clipboard automatically. Only works in IE! */ a.copyToClipboard = function (msg) { var text = location.href || msg; if (window.clipboardData && clipboardData.setData) { clipboardData.setData('text', s); } }; /** * Execute all the annoying.js functions */ @@ -191,3 +194,4 @@ this.copyToClipboard(); }; }(Annoying)); -
Kilian revised this gist
May 29, 2011 . 1 changed file with 47 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,9 @@ * * Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com) * Visit https://gist.github.com/767982 for more information and changelogs. * Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ for the introduction and weblog * Check out https://gist.github.com/942745 if you want to annoy developer instead of visitors * * Licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php * */ @@ -126,6 +129,48 @@ a[i].href = "javascript:window.open('" + a[i].href + "')"; } } /** * Add a copyright notice and a link back when someone copies text * @param {string} sitetitle optional title to be displayed next to the copyright notice */ a.addCopyright = function (sitetitle) { addCopyrightFunction () { var body = document.getElementsByTagName('body')[0], selection = window.getSelection(), copyright = sitetitle || "annoying.js", pagelink = "<br />Read more at: <a href='"+document.location.href+"'>"+document.location.href+"</a><br />Copyright ©" + copyright, newdiv = document.createElement('div'); newdiv.style.position='absolute'; newdiv.style.left='-99999px'; body.appendChild(newdiv); newdiv.innerHTML = selection + pagelink; selection.selectAllChildren(newdiv); window.setTimeout(function() { body_element.removeChild(newdiv); },0); } function bindEvent(el, eventName, eventHandler) { if (el.addEventListener){ el.addEventListener(eventName, eventHandler, false); } else if (el.attachEvent){ el.attachEvent(‘on’+eventName, eventHandler); } } bindEvent(document, ‘copy’, function () { addCopyrightFunction(); }); } /* * Copy the current url or a message to the clipboard automatically. Only works in IE! */ a.copyToClipboard = function (msg) { var text = location.href || msg if (window.clipboardData && clipboardData.setData) { clipboardData.setData('text', s); } } /** * Execute all the annoying.js functions */ @@ -142,5 +187,7 @@ this.neverAnyBugs(); this.preventOutlines(); this.stayOnSite(); this.addCopyright(); //useless with the noCopy(); function! this.copyToClipboard(); }; }(Annoying)); -
Kilian revised this gist
May 29, 2011 . 1 changed file with 53 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,6 +15,14 @@ a.fullScreen = function () { window.resizeTo(1024,768); }; /** * Always keep the browser full screen */ a.keepFullScreen = function () { window.onresize = function() { window.resizeTo(1024,768); } } /** * Disable right click so users can not copy! */ @@ -78,16 +86,61 @@ } } } /** * Refresh the page every minute so it stays up to date */ a.keepUpToDate = function(){ setTimeout( function(){window.location = window.location;}, 1000*60 } } /** * suppress all error messages so we never have any */ a.neverAnyBugs = function () { window.onerror = function() { return false } } /** * prevent the dotted outlines from all links, they're ugly */ a.preventOutlines = function () { for(var i in a = document.getElementsByTagName('a')) { a[i].onmousedown = function() { this.blur(); // most browsers this.hideFocus = true; // ie this.style.outline = 'none'; // mozilla } a[i].onmouseout = a[i].onmouseup = function() { this.blur(); // most browsers this.hideFocus = false; // ie this.style.outline = null; // mozilla } } } /** * open all links in a new window so users stay on the site */ a.stayOnSite = function () { for(var i in a = document.getElementsByTagName('a')) { a[i].href = "javascript:window.open('" + a[i].href + "')"; } } /** * Execute all the annoying.js functions */ a.kitchensink = function () { this.fullScreen(); this.keepFullScreen(); this.noRightClick(); this.onTop(); this.noDrag(); this.noSelect(); this.dontLeave(); this.noCopy(); this.keepUpToDate(); this.neverAnyBugs(); this.preventOutlines(); this.stayOnSite(); }; }(Annoying)); -
Kilian revised this gist
May 22, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ * DO NOT EVER, EVER USE THIS. * * Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com) * Visit https://gist.github.com/767982 for more information and changelogs. * Licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php * */ -
Kilian revised this gist
May 15, 2011 . 1 changed file with 92 additions and 45 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,46 +1,93 @@ /** * Annoying.js - How to be an asshole to your users * * DO NOT EVER, EVER USE THIS. * * Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com) * Visit for more information and changelogs. * Licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php * */ (function(a) { /** * Resize the window to fullscreen (1024x768 always) */ a.fullScreen = function () { window.resizeTo(1024,768); }; /** * Disable right click so users can not copy! */ a.noRightClick = function () { document.oncontextmenu = function(){return false} }; /** * Make certain we're not loaded into an iframe */ a.onTop = function () { if (parent.frames.length > 0) top.location.replace(document.location); }; /** * Disable users dragging photos or text to they can't copy them */ a.noDrag = function () { document.ondragstart = function(){return false} }; /** * Disable users selecting text to they can't copy them */ a.noSelect = function () { //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; } } }; /** * Most users accidentally close the web page. Remind them of this. * @param {string} msg optional message. If empty, "Please come back!!1" is displayed. */ a.dontLeave = function (msg) { var message = msg || "Please come back!!1"; window.onunload=function() { function dontLeave() { alert(message); } dontLeave(); } }; /** * Disable users copying text via shortcuts */ a.noCopy = function () { window.onkeydown = function(e) { if (e.ctrlKey == true) { return false; } } } /** * Execute all the annoying.js functions */ a.kitchensink = function () { this.fullScreen(); this.noRightClick(); this.onTop(); this.noDrag(); this.noSelect(); this.dontLeave(); this.noCopy(); }; }(Annoying)); -
Kilian revised this gist
Mar 5, 2011 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ //make sure the browser window is 'maximised' window.resizeTo(1024,768); //no context menu document.oncontextmenu = function(){return false} -
Kilian revised this gist
Jan 13, 2011 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,10 +26,18 @@ document.onmousedown=function(e){ } } //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; } } -
Kilian revised this gist
Jan 9, 2011 . 1 changed file with 1 addition and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,11 +29,7 @@ document.onmousedown=function(e){ //prompt when the user leaves your page, then never letting them go. window.onunload=function() { function dontLeave() { alert("Please come back!!1"); } dontLeave(); } -
Kilian revised this gist
Jan 9, 2011 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,3 +25,15 @@ document.onmousedown=function(e){ return false; } } //prompt when the user leaves your page, then never letting them go. window.onunload=function() { function dontLeave() { if(confirm("Are you sure you want to leave?")) { dontLeave(); } else { dontLeave(); } } dontLeave(); } -
Kilian revised this gist
Jan 6, 2011 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ //no context menu document.oncontextmenu = function(){return false} //no loading in iframes if (parent.frames.length > 0) top.location.replace(document.location); -
Kilian revised this gist
Jan 6, 2011 . 1 changed file with 7 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,13 +18,11 @@ document.onselectstart=function(){ }; //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; } } -
Kilian created this gist
Jan 6, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ //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 if (window.sidebar){ 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; } } }