-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpinboard.js
46 lines (37 loc) · 1.06 KB
/
pinboard.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
/* eslint-env browser, es6 */
/* eslint-disable no-unused-vars */
/* global browser */
const BASE_URL = 'https://pinboard.in'
function saveToPinboard (options = {url: '', title: '', description: '', readLater: false}) {
let {url, title, description, readLater} = options
let pinboardUrl = BASE_URL + '/add?'
let next = encodeURIComponent('/close')
let fullUrl = pinboardUrl + 'next=' + next +
'&url=' + encodeURIComponent(url) +
'&description=' + encodeURIComponent(description) +
'&title=' + encodeURIComponent(title)
if (readLater) {
fullUrl = pinboardUrl + 'later=yes&noui=yes&next=' + next +
'&url=' + encodeURIComponent(url) +
'&title=' + encodeURIComponent(title)
}
browser.windows.create({
url: fullUrl,
width: 660,
height: 400,
type: 'popup'
})
}
function saveToReadLater (options) {
saveToPinboard({...options, readLater: true})
}
function openUnreadBookmarks () {
browser.tabs.create({
url: BASE_URL + '/toread/'
})
}
function openAllBookmarks () {
browser.tabs.create({
url: BASE_URL
})
}