-
Notifications
You must be signed in to change notification settings - Fork 0
/
simpleshare.js
executable file
·48 lines (44 loc) · 1.81 KB
/
simpleshare.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$(document).ready(function() {
var SharingHeaderText = chrome.i18n.getMessage("SharingHeadingLabel");
$("div#SharingHeader").text(SharingHeaderText);
$("div.SharingService").click(function(event) {
// Figure out which service was clicked.
var ServiceId;
var target = $(event.target);
if (target.is(".SharingService")) {
ServiceId = target.attr("id");
}
else {
ServiceId = target.parent(".SharingService").attr("id");
}
// Get current tab.
chrome.tabs.getSelected(null, function(tab) {
// Get current tab URL.
currentUrl = encodeURIComponent(tab.url);
// Depending on which service was clicked, execute the
// appropriate sharing logic.
switch(ServiceId) {
case "FbShare":
var redirectUrl = encodeURIComponent("https://simpleshare-gae.appspot.com/LandingPages/RedirectedFromFacebook.html");
var shareUrl = "https://www.facebook.com/dialog/feed?app_id=590308774312476&display=popup&redirect_uri=" + redirectUrl + "&link=" + currentUrl;
chrome.windows.create({'url': shareUrl, 'width':580, 'height': 400, 'type': 'popup'});
break;
case "TwitterShare":
var intentUrl = "https://twitter.com/intent/tweet?url=" + currentUrl;
chrome.windows.create({'url': intentUrl, 'width':550, 'height': 420, 'type': 'popup'});
break;
case "GPlusShare":
var shareUrl = "https://plus.google.com/share?url=" + currentUrl;
chrome.windows.create({'url': shareUrl, 'width':550, 'height': 420, 'type': 'popup'});
break;
case "GMailShare":
var shareUrl = "https://mail.google.com/mail/?fs=1&view=cm&su&tf=1&shva=1&body=" + currentUrl;
chrome.windows.create({'url': shareUrl, 'width':550, 'height': 420, 'type': 'popup'});
break;
case "EmailShare":
chrome.extension.getBackgroundPage().createMail(currentUrl);
break;
}
});
});
});