diff --git a/Extension/Info.plist b/Extension/Info.plist index 5b0115c..0a39f69 100644 --- a/Extension/Info.plist +++ b/Extension/Info.plist @@ -35,30 +35,15 @@ script.js - SFSafariToolbarItem - - Action - Command - Identifier - Button - Image - ToolbarItemIcon.pdf - Label - Your Button - SFSafariWebsiteAccess - Allowed Domains - - *.webkit.org - Level - Some + All NSHumanReadableCopyright Copyright © 2018 Yannick Weiss. All rights reserved. NSHumanReadableDescription - This is a Safari Extension. You should tell us what your extension does here. + Extension brings back the Backspace diff --git a/Extension/script.js b/Extension/script.js index 34f7e35..e5c8245 100644 --- a/Extension/script.js +++ b/Extension/script.js @@ -1,3 +1,10 @@ document.addEventListener("DOMContentLoaded", function(event) { - safari.extension.dispatchMessage("Hello World!"); + function handleBackspace(e) { + if (e.keyCode === 8 && !e.ctrlKey && !e.shiftKey + && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA') { + e.preventDefault(); + window.history.go(-1); + } + } + window.addEventListener('keydown', handleBackspace, false); });