-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
42 lines (36 loc) · 972 Bytes
/
main.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
var curUrl = "";
var curTitle = "";
var curDescription = "";
var getUrl = false;
var getTitle = false;
var getDescription = false;
var finalUrl = "";
function setDefaults()
{
// retrieve the current tab's url and title
chrome.tabs.getSelected(null, function(tab) {
curUrl = tab.url;
getUrl = true;
curTitle = tab.title;
getTitle = true;
getDescriptionValue();
});
}
function getDescriptionValue()
{
chrome.tabs.getSelected(null, function(tab)
{
chrome.tabs.sendRequest(tab.id, {method: "getSelection"}, function (response) {
curDescription = response.data;
getDescription = true;
makeFinalUrl();
});
});
}
function makeFinalUrl()
{
finalUrl = 'https://pinboard.in/add?url='+encodeURIComponent(curUrl)+'&description='+encodeURIComponent(curDescription)+'&title='+encodeURIComponent(curTitle);
var frame = document.getElementById('pinboardsrc');
frame.src = finalUrl;
}
setDefaults();