Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
Basic support for Netflix, Youtube, Amazon Video, Twitch, and more
  • Loading branch information
amarcu5 committed Mar 2, 2017
0 parents commit 4e1b0b4
Show file tree
Hide file tree
Showing 17 changed files with 540 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

certs/privatekey.pem

certs/cert.pem
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# PiPer
Adds Picture in Picture functionality to Safari for Youtube, Netflix, Amazon Video, Twitch, and more!

## Installation

Get the extension [here](https://s3.amazonaws.com/piper-extension/PiPer.safariextz), open the downloaded file, and hit trust

## Supported sites
* [Youtube](http://www.youtube.com)
* [Netflix](http://www.netflix.com)
* [Amazon video](http://www.amazon.com/PrimeVideo)
* [Twitch](http://www.twitch.tv)
* [Metacafe](http://www.metacafe.com)
* [Openload](http://www.openload.co)
* [CollegeHumor](http://www.collegehumor.com)
* [Vevo](http://www.vevo.com)
* [Vid.me](http://www.vid.me)

## Acknowledgements
* [Pied PíPer](https://github.com/JoeKuhns/PiedPiPer.safariextension) for the original inspiration and the Netflix icon
* [Google](https://github.com/google/material-design-icons) for the Picture in Picture icon

## Build tools
* [svgo](https://github.com/svg/svgo) (0.7.2) for compressing SVG images
* [xarjs](https://github.com/robertknight/xar-js) (0.2.0) for packaging Safari extension
* [ccjs](https://github.com/google/closure-compiler-js) (1.6.1) for compiling JavaScript
* [plistbuddy](https://github.com/amarcu5/PiPer/tree/master/build-tools/) for automated build numbering - reimplementation of utility from [Apple's Command Line Tools](https://developer.apple.com/download/)
Binary file added build-tools/ccjs
Binary file not shown.
Binary file added build-tools/plistbuddy
Binary file not shown.
Binary file added build-tools/svgo
Binary file not shown.
Binary file added build-tools/xarjs
Binary file not shown.
25 changes: 25 additions & 0 deletions certs/apple-intermediate.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-----BEGIN CERTIFICATE-----
MIIEIjCCAwqgAwIBAgIIAd68xDltoBAwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UE
BhMCVVMxEzARBgNVBAoTCkFwcGxlIEluYy4xJjAkBgNVBAsTHUFwcGxlIENlcnRp
ZmljYXRpb24gQXV0aG9yaXR5MRYwFAYDVQQDEw1BcHBsZSBSb290IENBMB4XDTEz
MDIwNzIxNDg0N1oXDTIzMDIwNzIxNDg0N1owgZYxCzAJBgNVBAYTAlVTMRMwEQYD
VQQKDApBcHBsZSBJbmMuMSwwKgYDVQQLDCNBcHBsZSBXb3JsZHdpZGUgRGV2ZWxv
cGVyIFJlbGF0aW9uczFEMEIGA1UEAww7QXBwbGUgV29ybGR3aWRlIERldmVsb3Bl
ciBSZWxhdGlvbnMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3
DQEBAQUAA4IBDwAwggEKAoIBAQDKOFSmy1aqyCQ5SOmM7uxfuH8mkbw0U3rOfGOA
YXdkXqUHI7Y5/lAtFVZYcC1+xG7BSoU+L/DehBqhV8mvexj/avoVEkkVCBmsqtsq
Mu2WY2hSFT2Miuy/axiV4AOsAX2XBWfODoWVN2rtCbauZ81RZJ/GXNG8V25nNYB2
NqSHgW44j9grFU57Jdhav06DwY3Sk9UacbVgnJ0zTlX5ElgMhrgWDcHld0WNUEi6
Ky3klIXh6MSdxmilsKP8Z35wugJZS3dCkTm59c3hTO/AO0iMpuUhXf1qarunFjVg
0uat80YpyejDi+l5wGphZxWy8P3laLxiX27Pmd3vG2P+kmWrAgMBAAGjgaYwgaMw
HQYDVR0OBBYEFIgnFwmpthhgi+zruvZHWcVSVKO3MA8GA1UdEwEB/wQFMAMBAf8w
HwYDVR0jBBgwFoAUK9BpR5R2Cf70a40uQKb3R01/CF4wLgYDVR0fBCcwJTAjoCGg
H4YdaHR0cDovL2NybC5hcHBsZS5jb20vcm9vdC5jcmwwDgYDVR0PAQH/BAQDAgGG
MBAGCiqGSIb3Y2QGAgEEAgUAMA0GCSqGSIb3DQEBBQUAA4IBAQBPz+9Zviz1smwv
j+4ThzLoBTWobot9yWkMudkXvHcs1Gfi/ZptOllc34MBvbKuKmFysa/Nw0Uwj6OD
Dc4dR7Txk4qjdJukw5hyhzs+r0ULklS5MruQGFNrCk4QttkdUGwhgAqJTleMa1s8
Pab93vcNIx0LSiaHP7qRkkykGRIZbVf1eliHe2iK5IaMSuviSRSqpd1VAKmuu0sw
ruGgsbwpgOYJd+W+NKIByn/c4grmO7i77LpilfMFY0GCzQ87HUyVpNur+cmV6U/k
TecmmYHpvPm0KdIBembhLoz2IYrF+Hjhga6/05Cdqa3zr/04GpZnMBxRpVzscYqC
tGwPDBUf
-----END CERTIFICATE-----
28 changes: 28 additions & 0 deletions certs/apple-root.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN CERTIFICATE-----
MIIEuzCCA6OgAwIBAgIBAjANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQGEwJVUzET
MBEGA1UEChMKQXBwbGUgSW5jLjEmMCQGA1UECxMdQXBwbGUgQ2VydGlmaWNhdGlv
biBBdXRob3JpdHkxFjAUBgNVBAMTDUFwcGxlIFJvb3QgQ0EwHhcNMDYwNDI1MjE0
MDM2WhcNMzUwMjA5MjE0MDM2WjBiMQswCQYDVQQGEwJVUzETMBEGA1UEChMKQXBw
bGUgSW5jLjEmMCQGA1UECxMdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx
FjAUBgNVBAMTDUFwcGxlIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
ggEKAoIBAQDkkakJH5HbHkdQ6wXtXnmELes2oldMVeyLGYne+Uts9QerIjAC6Bg+
+FAJ039BqJj50cpmnCRrEdCju+QbKsMflZ56DKRHi1vUFjczy8QPTc4UadHJGXL1
XQ7Vf1+b8iU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NVxnn6hUrcbvZNCJBIqxw8dtk2cXmPIS4AX
UKqK1drk/NAJBzewdXUh
-----END CERTIFICATE-----
73 changes: 73 additions & 0 deletions make.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/sh

#
# Settings
#

EXTENSION_NAME="PiPer"

# Paths
CCJS_PATH="./build-tools/ccjs" # "ccjs"
XARJS_PATH="./build-tools/xarjs" # "xarjs"
SVGO_PATH="./build-tools/svgo" # "svgo"
PLISTBUDDY_PATH="./build-tools/plistbuddy" # "/usr/libexec/PlistBuddy"

# Certifcates
LEAF_CERT_PATH="../certs/cert.pem"
INTERMEDIATE_CERT_PATH="../certs/apple-intermediate.pem"
ROOT_CERT_PATH="../certs/apple-root.pem"
PRIVATE_KEY_PATH="../certs/privatekey.pem"


#
# Build script
#

# Set working directory to project root
cd $(cd -P -- "$(dirname -- "$0")" && pwd -P)

# Remove output folder
rm -rf out

# Make output folder
mkdir -p "out/${EXTENSION_NAME}.safariextension"

# Copy items into output folder
cp -r src/* "out/${EXTENSION_NAME}.safariextension/"

# Compress all supported images with SVGO
${SVGO_PATH} -q -f "out/${EXTENSION_NAME}.safariextension/images"

# Use closure compiler to compress javascript
${CCJS_PATH} out/${EXTENSION_NAME}.safariextension/scripts/main.js \
--compilation_level=ADVANCED_OPTIMIZATIONS \
--warning_level=VERBOSE \
--externs="out/${EXTENSION_NAME}.safariextension/scripts/externs.js" \
--new_type_inf \
--use_types_for_optimization \
> out/${EXTENSION_NAME}.safariextension/scripts/main.min.js
mv out/${EXTENSION_NAME}.safariextension/scripts/main.min.js out/${EXTENSION_NAME}.safariextension/scripts/main.js
rm out/${EXTENSION_NAME}.safariextension/scripts/externs.js

# Update version info from git
git=$(sh /etc/profile; which git)
number_of_commits=$(($("$git" rev-list HEAD --count) + 1))
git_release_version=$("$git" describe --tags --always --abbrev=0)
git_release_version=${git_release_version%%-*};
git_release_version=${git_release_version#*v};
info_plist="out/${EXTENSION_NAME}.safariextension/Info.plist"
update_plist="update.plist"
${PLISTBUDDY_PATH} -c "Set :CFBundleVersion $number_of_commits" "$info_plist"
${PLISTBUDDY_PATH} -c "Set :CFBundleShortVersionString ${git_release_version}" "$info_plist"
${PLISTBUDDY_PATH} -c "Set \":Extension Updates:0:CFBundleVersion\" $number_of_commits" "$update_plist"
${PLISTBUDDY_PATH} -c "Set \":Extension Updates:0:CFBundleShortVersionString\" ${git_release_version#*v}" "$update_plist"

# Package safari extension
cd out
if [[ ${XARJS_PATH} != /* ]]; then if ! [ command -v "${XARJS_PATH}" >/dev/null 2>&1 ]; then XARJS_PATH="../${XARJS_PATH}"; fi; fi
${XARJS_PATH} create "${EXTENSION_NAME}.safariextz" --cert "${LEAF_CERT_PATH}" --cert "${INTERMEDIATE_CERT_PATH}" --cert "${ROOT_CERT_PATH}" --private-key "${PRIVATE_KEY_PATH}" "${EXTENSION_NAME}.safariextension"

# Remove unpacked extension
if [ -f "${PRIVATE_KEY_PATH}" ]; then rm -rf "${EXTENSION_NAME}.safariextension"; fi

echo "Done."
Binary file added out/PiPer.safariextz
Binary file not shown.
Binary file added src/Icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions src/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?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>Author</key>
<string>Adam Marcus</string>
<key>Builder Version</key>
<string>12602.4.8</string>
<key>CFBundleDisplayName</key>
<string>PiPer</string>
<key>CFBundleIdentifier</key>
<string>com.amarcus.safari.piper</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
<string>0.0</string>
<key>CFBundleVersion</key>
<string>0</string>
<key>Content</key>
<dict>
<key>Scripts</key>
<dict>
<key>End</key>
<array>
<string>scripts/main.js</string>
</array>
</dict>
</dict>
<key>Description</key>
<string>Adds Picture in Picture functionality to Youtube, Netflix, Amazon Video, Twitch, and more!</string>
<key>DeveloperIdentifier</key>
<string>BQ6Q24MF9X</string>
<key>ExtensionInfoDictionaryVersion</key>
<string>1.0</string>
<key>Update Manifest URL</key>
<string>https://s3.amazonaws.com/piper-extension/update.plist</string>
<key>Website</key>
<string>https://github.com/amarcu5/PiPer/</string>
<key>Permissions</key>
<dict>
<key>Website Access</key>
<dict>
<key>Allowed Domains</key>
<array>
<string>*.amazon.co.uk</string>
<string>*.amazon.com</string>
<string>*.amazon.fr</string>
<string>*.amazon.de</string>
<string>*.amazon.ca</string>
<string>*.netflix.com</string>
<string>netflix.com</string>
<string>*.youtube.com</string>
<string>youtube.com</string>
<string>*.twitch.tv</string>
<string>twitch.tv</string>
<string>*.metacafe.com</string>
<string>metacafe.com</string>
<string>*.openload.co</string>
<string>openload.co</string>
<string>*.vevo.com</string>
<string>vevo.com</string>
<string>*.collegehumor.com</string>
<string>collegehumor.com</string>
<string>vid.me</string>
<string>*.vid.me</string>
</array>
<key>Include Secure Pages</key>
<true/>
<key>Level</key>
<string>Some</string>
</dict>
</dict>
</dict>
</plist>
4 changes: 4 additions & 0 deletions src/images/default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/images/netflix.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/scripts/externs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @const */
var safari = {};

/** @const */
safari.extension = {};

/** @type {string} */
safari.extension.baseURI;

/** @type {string} */
HTMLVideoElement.prototype.webkitPresentationMode;

/** @return {undefined} */
HTMLVideoElement.prototype.webkitSetPresentationMode = function(mode) {}
Loading

0 comments on commit 4e1b0b4

Please sign in to comment.