Skip to content

Instantly share code, notes, and snippets.

@mildmojo
Created November 2, 2013 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mildmojo/7273987 to your computer and use it in GitHub Desktop.
Save mildmojo/7273987 to your computer and use it in GitHub Desktop.
Saves your bacon when you're using jsbin.com with OS X and try to Cmd+Left to go to the beginning of the line.
// ==UserScript==
// @name Permission to Leave
// @namespace permission.to.leave
// @description Prompts before leaving the page. Good for OS X users who press Cmd+Left while editing text to go to the start of the line, only to find the browser goes back a page instead.
// @version 1.0
// @grant none
// @include http://edit.script.and
// @include https://add.target.sites.here
// @include https://twitter.com
// ==/UserScript==
window.addEventListener('beforeunload', function(e) {
var confirmationMessage = "Brought to you by the Permission to Leave user script.";
(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment