Skip to content

Commit

Permalink
Ignoring contentEditable containers like TinyMCE
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick Weiss committed Oct 24, 2018
1 parent 5b7af7b commit 5548e52
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Extension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Extension</string>
<string>Backspace</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand Down Expand Up @@ -44,6 +44,6 @@
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 Yannick Weiss. All rights reserved.</string>
<key>NSHumanReadableDescription</key>
<string>Extension brings back the Backspace</string>
<string>This extension brings back the Backspace.</string>
</dict>
</plist>
4 changes: 3 additions & 1 deletion Extension/script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
document.addEventListener("DOMContentLoaded", function(event) {
function handleBackspace(e) {
if (e.keyCode === 8 && !e.ctrlKey && !e.shiftKey
&& e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA') {
&& e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA'
&& e.target.contentEditable !== 'true' // TinyMCE
) {
e.preventDefault();
window.history.go(-1);
}
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Safari Backspace

Because macOS Mojave removed the Backspace.

## The injected script
```javascript
function handleBackspace(e) {
if (e.keyCode === 8 && !e.ctrlKey && !e.shiftKey
&& e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA'
&& e.target.contentEditable !== 'true' // TinyMCE
) {
e.preventDefault();
window.history.go(-1);
}
}
window.addEventListener('keydown', handleBackspace, false);

```

## Paranoid People 🙈
I am recording your text inputs and send it to my servers, so I can laugh about your spelling mistakes.

You can find the scripts in the release by inspecting the package contents.

`open Safari\ Backspace.app/Contents/PlugIns/Backspace.appex/Contents/Resources/`

144 changes: 144 additions & 0 deletions Safari Backspace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,39 @@
ACEBD69B2178DFC60051E5E6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ACEBD69A2178DFC60051E5E6 /* Assets.xcassets */; };
ACEBD69E2178DFC60051E5E6 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = ACEBD69C2178DFC60051E5E6 /* MainMenu.xib */; };
ACEBD6A12178DFC60051E5E6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ACEBD6A02178DFC60051E5E6 /* main.m */; };
ACEBD6AF2178DFDB0051E5E6 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ACEBD6AE2178DFDB0051E5E6 /* Cocoa.framework */; };
ACEBD6B32178DFDB0051E5E6 /* SafariExtensionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = ACEBD6B22178DFDB0051E5E6 /* SafariExtensionHandler.m */; };
ACEBD6B62178DFDB0051E5E6 /* SafariExtensionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ACEBD6B52178DFDB0051E5E6 /* SafariExtensionViewController.m */; };
ACEBD6B92178DFDB0051E5E6 /* SafariExtensionViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = ACEBD6B72178DFDB0051E5E6 /* SafariExtensionViewController.xib */; };
ACEBD6BC2178DFDB0051E5E6 /* script.js in Resources */ = {isa = PBXBuildFile; fileRef = ACEBD6BB2178DFDB0051E5E6 /* script.js */; };
ACEBD6BE2178DFDB0051E5E6 /* ToolbarItemIcon.pdf in Resources */ = {isa = PBXBuildFile; fileRef = ACEBD6BD2178DFDB0051E5E6 /* ToolbarItemIcon.pdf */; };
ACEBD6C22178DFDB0051E5E6 /* Backspace.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = ACEBD6AC2178DFDB0051E5E6 /* Backspace.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
ACEBD6C02178DFDB0051E5E6 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = ACEBD68C2178DFC50051E5E6 /* Project object */;
proxyType = 1;
remoteGlobalIDString = ACEBD6AB2178DFDB0051E5E6;
remoteInfo = Extension;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
ACEBD6C62178DFDB0051E5E6 /* Embed App Extensions */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 13;
files = (
ACEBD6C22178DFDB0051E5E6 /* Backspace.appex in Embed App Extensions */,
);
name = "Embed App Extensions";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
ACEBD6942178DFC50051E5E6 /* Safari Backspace.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Safari Backspace.app"; sourceTree = BUILT_PRODUCTS_DIR; };
ACEBD6972178DFC50051E5E6 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand All @@ -22,6 +53,17 @@
ACEBD69F2178DFC60051E5E6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
ACEBD6A02178DFC60051E5E6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
ACEBD6A22178DFC60051E5E6 /* Safari_Backspace.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Safari_Backspace.entitlements; sourceTree = "<group>"; };
ACEBD6AC2178DFDB0051E5E6 /* Backspace.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = Backspace.appex; sourceTree = BUILT_PRODUCTS_DIR; };
ACEBD6AE2178DFDB0051E5E6 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
ACEBD6B12178DFDB0051E5E6 /* SafariExtensionHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SafariExtensionHandler.h; sourceTree = "<group>"; };
ACEBD6B22178DFDB0051E5E6 /* SafariExtensionHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SafariExtensionHandler.m; sourceTree = "<group>"; };
ACEBD6B42178DFDB0051E5E6 /* SafariExtensionViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SafariExtensionViewController.h; sourceTree = "<group>"; };
ACEBD6B52178DFDB0051E5E6 /* SafariExtensionViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SafariExtensionViewController.m; sourceTree = "<group>"; };
ACEBD6B82178DFDB0051E5E6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SafariExtensionViewController.xib; sourceTree = "<group>"; };
ACEBD6BA2178DFDB0051E5E6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
ACEBD6BB2178DFDB0051E5E6 /* script.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = script.js; sourceTree = "<group>"; };
ACEBD6BD2178DFDB0051E5E6 /* ToolbarItemIcon.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = ToolbarItemIcon.pdf; sourceTree = "<group>"; };
ACEBD6BF2178DFDB0051E5E6 /* Extension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Extension.entitlements; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -32,13 +74,23 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
ACEBD6A92178DFDB0051E5E6 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
ACEBD6AF2178DFDB0051E5E6 /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
ACEBD68B2178DFC50051E5E6 = {
isa = PBXGroup;
children = (
ACEBD6962178DFC50051E5E6 /* Safari Backspace */,
ACEBD6B02178DFDB0051E5E6 /* Extension */,
ACEBD6AD2178DFDB0051E5E6 /* Frameworks */,
ACEBD6952178DFC50051E5E6 /* Products */,
);
sourceTree = "<group>";
Expand All @@ -47,6 +99,7 @@
isa = PBXGroup;
children = (
ACEBD6942178DFC50051E5E6 /* Safari Backspace.app */,
ACEBD6AC2178DFDB0051E5E6 /* Backspace.appex */,
);
name = Products;
sourceTree = "<group>";
Expand All @@ -65,6 +118,30 @@
path = "Safari Backspace";
sourceTree = "<group>";
};
ACEBD6AD2178DFDB0051E5E6 /* Frameworks */ = {
isa = PBXGroup;
children = (
ACEBD6AE2178DFDB0051E5E6 /* Cocoa.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
ACEBD6B02178DFDB0051E5E6 /* Extension */ = {
isa = PBXGroup;
children = (
ACEBD6B12178DFDB0051E5E6 /* SafariExtensionHandler.h */,
ACEBD6B22178DFDB0051E5E6 /* SafariExtensionHandler.m */,
ACEBD6B42178DFDB0051E5E6 /* SafariExtensionViewController.h */,
ACEBD6B52178DFDB0051E5E6 /* SafariExtensionViewController.m */,
ACEBD6B72178DFDB0051E5E6 /* SafariExtensionViewController.xib */,
ACEBD6BA2178DFDB0051E5E6 /* Info.plist */,
ACEBD6BB2178DFDB0051E5E6 /* script.js */,
ACEBD6BD2178DFDB0051E5E6 /* ToolbarItemIcon.pdf */,
ACEBD6BF2178DFDB0051E5E6 /* Extension.entitlements */,
);
path = Extension;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -75,16 +152,35 @@
ACEBD6902178DFC50051E5E6 /* Sources */,
ACEBD6912178DFC50051E5E6 /* Frameworks */,
ACEBD6922178DFC50051E5E6 /* Resources */,
ACEBD6C62178DFDB0051E5E6 /* Embed App Extensions */,
);
buildRules = (
);
dependencies = (
ACEBD6C12178DFDB0051E5E6 /* PBXTargetDependency */,
);
name = "Safari Backspace";
productName = "Safari Backspace";
productReference = ACEBD6942178DFC50051E5E6 /* Safari Backspace.app */;
productType = "com.apple.product-type.application";
};
ACEBD6AB2178DFDB0051E5E6 /* Backspace */ = {
isa = PBXNativeTarget;
buildConfigurationList = ACEBD6C32178DFDB0051E5E6 /* Build configuration list for PBXNativeTarget "Backspace" */;
buildPhases = (
ACEBD6A82178DFDB0051E5E6 /* Sources */,
ACEBD6A92178DFDB0051E5E6 /* Frameworks */,
ACEBD6AA2178DFDB0051E5E6 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Backspace;
productName = Extension;
productReference = ACEBD6AC2178DFDB0051E5E6 /* Backspace.appex */;
productType = "com.apple.product-type.app-extension";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
Expand All @@ -97,6 +193,9 @@
ACEBD6932178DFC50051E5E6 = {
CreatedOnToolsVersion = 10.0;
};
ACEBD6AB2178DFDB0051E5E6 = {
CreatedOnToolsVersion = 10.0;
};
};
};
buildConfigurationList = ACEBD68F2178DFC50051E5E6 /* Build configuration list for PBXProject "Safari Backspace" */;
Expand All @@ -113,6 +212,7 @@
projectRoot = "";
targets = (
ACEBD6932178DFC50051E5E6 /* Safari Backspace */,
ACEBD6AB2178DFDB0051E5E6 /* Backspace */,
);
};
/* End PBXProject section */
Expand All @@ -127,6 +227,16 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
ACEBD6AA2178DFDB0051E5E6 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
ACEBD6BE2178DFDB0051E5E6 /* ToolbarItemIcon.pdf in Resources */,
ACEBD6B92178DFDB0051E5E6 /* SafariExtensionViewController.xib in Resources */,
ACEBD6BC2178DFDB0051E5E6 /* script.js in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand All @@ -139,8 +249,25 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
ACEBD6A82178DFDB0051E5E6 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
ACEBD6B62178DFDB0051E5E6 /* SafariExtensionViewController.m in Sources */,
ACEBD6B32178DFDB0051E5E6 /* SafariExtensionHandler.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
ACEBD6C12178DFDB0051E5E6 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = ACEBD6AB2178DFDB0051E5E6 /* Backspace */;
targetProxy = ACEBD6C02178DFDB0051E5E6 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
ACEBD69C2178DFC60051E5E6 /* MainMenu.xib */ = {
isa = PBXVariantGroup;
Expand All @@ -150,6 +277,14 @@
name = MainMenu.xib;
sourceTree = "<group>";
};
ACEBD6B72178DFDB0051E5E6 /* SafariExtensionViewController.xib */ = {
isa = PBXVariantGroup;
children = (
ACEBD6B82178DFDB0051E5E6 /* Base */,
);
name = SafariExtensionViewController.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down Expand Up @@ -321,6 +456,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
ACEBD6C32178DFDB0051E5E6 /* Build configuration list for PBXNativeTarget "Backspace" */ = {
isa = XCConfigurationList;
buildConfigurations = (
ACEBD6C42178DFDB0051E5E6 /* Debug */,
ACEBD6C52178DFDB0051E5E6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = ACEBD68C2178DFC50051E5E6 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>Backspace.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>Extension.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>Safari Backspace.xcscheme</key>
<dict>
<key>orderHint</key>
Expand Down
28 changes: 10 additions & 18 deletions Safari Backspace/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate">
<connections>
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
Expand Down Expand Up @@ -682,40 +682,32 @@
<window title="Safari Backspace" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="467" height="127"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
<rect key="contentRect" x="335" y="390" width="459" height="85"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="467" height="127"/>
<rect key="frame" x="0.0" y="0.0" width="459" height="85"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DPN-fB-OLd">
<rect key="frame" x="0.0" y="0.0" width="128" height="128"/>
<rect key="frame" x="9" y="3" width="83" height="83"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="Image" id="YRY-Mw-mWc"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wYv-cn-VWS">
<rect key="frame" x="121" y="90" width="161" height="25"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Safari Backspace" id="zkt-XM-atu">
<font key="font" metaFont="system" size="21"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3XC-Zy-Eqx">
<rect key="frame" x="121" y="0.0" width="328" height="88"/>
<rect key="frame" x="93" y="4" width="348" height="61"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" id="Mcu-q2-noP">
<font key="font" metaFont="system" size="16"/>
<string key="title">Please open Safari &gt; Extension and enable the extension.
If the app is not signed you have to enable: Develop &gt; Allow unsigned Extensions</string>
<string key="title">Please open Safari &gt; Preferences &gt; Extensions and enable the Backspace Extension.

</string>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
<point key="canvasLocation" x="132.5" y="30.5"/>
<point key="canvasLocation" x="128.5" y="9.5"/>
</window>
</objects>
<resources>
Expand Down

0 comments on commit 5548e52

Please sign in to comment.