Skip to content

Commit

Permalink
The Safari Extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick Weiss committed Oct 22, 2018
1 parent 21d4d67 commit 5b7af7b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
19 changes: 2 additions & 17 deletions Extension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,15 @@
<string>script.js</string>
</dict>
</array>
<key>SFSafariToolbarItem</key>
<dict>
<key>Action</key>
<string>Command</string>
<key>Identifier</key>
<string>Button</string>
<key>Image</key>
<string>ToolbarItemIcon.pdf</string>
<key>Label</key>
<string>Your Button</string>
</dict>
<key>SFSafariWebsiteAccess</key>
<dict>
<key>Allowed Domains</key>
<array>
<string>*.webkit.org</string>
</array>
<key>Level</key>
<string>Some</string>
<string>All</string>
</dict>
</dict>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 Yannick Weiss. All rights reserved.</string>
<key>NSHumanReadableDescription</key>
<string>This is a Safari Extension. You should tell us what your extension does here.</string>
<string>Extension brings back the Backspace</string>
</dict>
</plist>
9 changes: 8 additions & 1 deletion Extension/script.js
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit 5b7af7b

Please sign in to comment.