-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bootstrap Safari App Extension project
- Loading branch information
Showing
27 changed files
with
3,663 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
|
||
# Created by https://www.gitignore.io/api/swift | ||
|
||
### Swift ### | ||
# Xcode | ||
# | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
## Build generated | ||
build/ | ||
DerivedData/ | ||
|
||
## Various settings | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata/ | ||
|
||
## Other | ||
*.moved-aside | ||
*.xccheckout | ||
*.xcscmblueprint | ||
|
||
## Obj-C/Swift specific | ||
*.hmap | ||
*.ipa | ||
*.dSYM.zip | ||
*.dSYM | ||
|
||
## Playgrounds | ||
timeline.xctimeline | ||
playground.xcworkspace | ||
|
||
# Swift Package Manager | ||
# | ||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. | ||
# Packages/ | ||
# Package.pins | ||
# Package.resolved | ||
.build/ | ||
|
||
# CocoaPods | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# | ||
# Pods/ | ||
# | ||
# Add this line if you want to avoid checking in source code from the Xcode workspace | ||
# *.xcworkspace | ||
|
||
# Carthage | ||
# | ||
# Add this line if you want to avoid checking in source code from Carthage dependencies. | ||
# Carthage/Checkouts | ||
|
||
Carthage/Build | ||
|
||
# fastlane | ||
# | ||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the | ||
# screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://docs.fastlane.tools/best-practices/source-control/#source-control | ||
|
||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots/**/*.png | ||
fastlane/test_output | ||
|
||
|
||
# End of https://www.gitignore.io/api/swift | ||
|
30 changes: 30 additions & 0 deletions
30
app_extension/vimari/extension/Base.lproj/SafariExtensionViewController.xib
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11134"/> | ||
</dependencies> | ||
<objects> | ||
<customObject id="-2" userLabel="File's Owner" customClass="SafariExtensionViewController" customModuleProvider="target"> | ||
<connections> | ||
<outlet property="view" destination="c22-O7-iKe" id="vwT-Xx-Aiz"/> | ||
</connections> | ||
</customObject> | ||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> | ||
<customObject id="-3" userLabel="Application" customClass="NSObject"/> | ||
<customView id="c22-O7-iKe"> | ||
<rect key="frame" x="0.0" y="0.0" width="330" height="119"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> | ||
<subviews> | ||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4Iy-aV-wGF"> | ||
<rect key="frame" x="103" y="82" width="124" height="17"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> | ||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="extension" id="2Ec-kd-q2K"> | ||
<font key="font" metaFont="system"/> | ||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> | ||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> | ||
</textFieldCell> | ||
</textField> | ||
</subviews> | ||
</customView> | ||
</objects> | ||
</document> |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>vimari</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>XPC!</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>2.0.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>2</string> | ||
<key>LSMinimumSystemVersion</key> | ||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>SFSafariStyleSheet</key> | ||
<array> | ||
<dict> | ||
<key>Style Sheet</key> | ||
<string>injected.css</string> | ||
</dict> | ||
</array> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.Safari.extension</string> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).SafariExtensionHandler</string> | ||
<key>SFSafariContentScript</key> | ||
<array> | ||
<dict> | ||
<key>Script</key> | ||
<string>settings.js</string> | ||
</dict> | ||
<dict> | ||
<key>Script</key> | ||
<string>keyboard-utils.js</string> | ||
</dict> | ||
<dict> | ||
<key>Script</key> | ||
<string>vimium-scripts.js</string> | ||
</dict> | ||
<dict> | ||
<key>Script</key> | ||
<string>link-hints.js</string> | ||
</dict> | ||
<dict> | ||
<key>Script</key> | ||
<string>mousetrap.js</string> | ||
</dict> | ||
<dict> | ||
<key>Script</key> | ||
<string>injected.js</string> | ||
</dict> | ||
</array> | ||
<key>SFSafariWebsiteAccess</key> | ||
<dict> | ||
<key>Level</key> | ||
<string>All</string> | ||
</dict> | ||
</dict> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>MIT license</string> | ||
<key>NSHumanReadableDescription</key> | ||
<string>Safari port of vimium</string> | ||
</dict> | ||
</plist> |
34 changes: 34 additions & 0 deletions
34
app_extension/vimari/extension/SafariExtensionHandler.swift
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// SafariExtensionHandler.swift | ||
// extension | ||
// | ||
// Created by Simon on 2018-07-13. | ||
// Copyright © 2018 vimari. All rights reserved. | ||
// | ||
|
||
import SafariServices | ||
|
||
class SafariExtensionHandler: SFSafariExtensionHandler { | ||
|
||
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String : Any]?) { | ||
// This method will be called when a content script provided by your extension calls safari.extension.dispatchMessage("message"). | ||
page.getPropertiesWithCompletionHandler { properties in | ||
NSLog("The extension received a message (\(messageName)) from a script injected into (\(String(describing: properties?.url))) with userInfo (\(userInfo ?? [:]))") | ||
} | ||
} | ||
|
||
override func toolbarItemClicked(in window: SFSafariWindow) { | ||
// This method will be called when your toolbar item is clicked. | ||
NSLog("The extension's toolbar item was clicked") | ||
} | ||
|
||
override func validateToolbarItem(in window: SFSafariWindow, validationHandler: @escaping ((Bool, String) -> Void)) { | ||
// This is called when Safari's state changed in some way that would require the extension's toolbar item to be validated again. | ||
validationHandler(true, "") | ||
} | ||
|
||
override func popoverViewController() -> SFSafariExtensionViewController { | ||
return SafariExtensionViewController.shared | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
app_extension/vimari/extension/SafariExtensionViewController.swift
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// SafariExtensionViewController.swift | ||
// extension | ||
// | ||
// Created by Simon on 2018-07-13. | ||
// Copyright © 2018 vimari. All rights reserved. | ||
// | ||
|
||
import SafariServices | ||
|
||
class SafariExtensionViewController: SFSafariExtensionViewController { | ||
|
||
static let shared = SafariExtensionViewController() | ||
|
||
} |
Oops, something went wrong.