Last active
August 29, 2015 14:12
-
-
Save Cam/f66fb1f60345acb3639a to your computer and use it in GitHub Desktop.
Fancy Safari Extension
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
<!DOCTYPE html> | |
<html> | |
<title>Fancy</title> | |
<script> | |
// Watch the extension for a trigger | |
safari.application.addEventListener("command", performCommand, false); | |
// Do something when triggered | |
function performCommand(event) { | |
// Pass that command we created before to this script | |
if (event.command == "FancyIt") { | |
var myurl = safari.application.activeBrowserWindow.activeTab.url; // Set current tab URL | |
var mytitle = safari.application.activeBrowserWindow.activeTab.title; // Set current tab title | |
var newTab = safari.application.activeBrowserWindow.openTab(); // Open a new tab | |
newTab.url = ('http://fancy.com/fancyit?ItemURL=' + encodeURIComponent(myurl) + '&Title=' + encodeURIComponent(mytitle)); // Set up share url | |
} | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment