Log in to Pinboard
4 | 5 |You must log in to Pinboard first using the API token 6 | that you can find on your 7 | Pinboard password page.
8 | 9 | 26 | 27 |├── .browserslistrc
├── .editorconfig
├── .gitignore
├── .stylelintrc
├── DEVELOP.md
├── LICENSE
├── PRIVACY.md
├── README.md
├── angular.json
├── package-lock.json
├── package.json
├── screenshots
├── pinboard-pin-dark.png
├── pinboard-pin-light.png
└── pinboard-pin-settings.png
├── src
├── app
│ ├── app.component.ts
│ ├── app.module.ts
│ ├── background
│ │ └── background.component.ts
│ ├── guard.ts
│ ├── icon.service.ts
│ ├── index.ts
│ ├── interval.pipe.ts
│ ├── login
│ │ ├── login.component.html
│ │ ├── login.component.scss
│ │ └── login.component.ts
│ ├── options
│ │ ├── options.component.html
│ │ ├── options.component.scss
│ │ └── options.component.ts
│ ├── pinboard.service.ts
│ ├── pinpage
│ │ ├── pinpage.component.html
│ │ ├── pinpage.component.scss
│ │ └── pinpage.component.ts
│ └── storage.service.ts
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── img
│ ├── pinboard_128.png
│ ├── pinboard_16.png
│ ├── pinboard_24.png
│ ├── pinboard_256.png
│ ├── pinboard_32.png
│ ├── pinboard_48.png
│ ├── pinboard_64.png
│ ├── pinboard_96.png
│ ├── pinboard_idle_128.png
│ ├── pinboard_idle_16.png
│ ├── pinboard_idle_24.png
│ ├── pinboard_idle_256.png
│ ├── pinboard_idle_32.png
│ ├── pinboard_idle_48.png
│ ├── pinboard_idle_64.png
│ └── pinboard_idle_96.png
├── index.html
├── js
│ └── content.js
├── main.ts
├── manifest.json
├── polyfills.ts
└── styles.scss
├── tsconfig.app.json
├── tsconfig.json
└── tslint.json
/.browserslistrc:
--------------------------------------------------------------------------------
1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 |
5 | # For the full list of supported browsers by the Angular framework, please see:
6 | # https://angular.io/guide/browser-support
7 |
8 | # You can see what browsers were selected by your queries by running:
9 | # npx browserslist
10 |
11 | last 1 Firefox version
12 | Firefox ESR
13 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # cache
4 | .angular/cache
5 | .nx/cache
6 |
7 | # compiled output
8 | /dist
9 | /tmp
10 | /out-tsc
11 |
12 | # dependencies
13 | /node_modules
14 |
15 | # built extensions
16 | *.xpi
17 | *.zip
18 |
19 | # IDEs and editors
20 | .idea/
21 | .project/
22 | .classpath
23 | .c9/
24 | *.launch
25 | .settings/
26 | *.sublime-workspace
27 | .vscode/
28 |
29 | # misc
30 | /.sass-cache
31 | /connect.lock
32 | /coverage
33 | /libpeerconnection.log
34 | npm-debug.log
35 | /typings
36 |
37 | # System Files
38 | .DS_Store
39 | Thumbs.db
40 |
--------------------------------------------------------------------------------
/.stylelintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "stylelint-config-standard"
3 | }
4 |
--------------------------------------------------------------------------------
/DEVELOP.md:
--------------------------------------------------------------------------------
1 | Development Notes for Pinboard Pin
2 | ==================================
3 |
4 | This is an add-on for pinning pages on [Pinboard](https://pinboard.in) in the web browser, based on the [WebExtensions](https://developer.mozilla.org/de/Add-ons/WebExtensions) system. This web extension has been developed for and tested with Firefox 80 for Windows and Linux. Since WebExtensions was created as a cross-browser standard, it should be portable to other platforms and web browsers like Chrome, Opera or Edge with only few adaptations.
5 |
6 | The web extension has been created using [Angular](https://angular.io/) and the [Angular CLI](https://github.com/angular/angular-cli).
7 |
8 | Installation
9 | ------------
10 |
11 | Install the application for development:
12 |
13 | npm install
14 |
15 | Building and testing
16 | --------------------
17 |
18 | Build extension for development:
19 |
20 | npm run build
21 |
22 | Test extension with Firefox:
23 |
24 | npm run test
25 |
26 | Build unsigned extension for production:
27 |
28 | npm run build:prod
29 |
30 | Package unsigned extension as zip file:
31 |
32 | npm run build:zip
33 |
34 | Known issues
35 | ------------
36 |
37 | * Due to limitations in the Web-Ext API, the keyboard shortcut (Alt+P) cannot be changed or deactivated (at least I don't see a simple way how to do this - let me know if I'm overlooking something).
38 |
39 | * Unfortunately, storing tabsets is not supported by the Pinboard API. Therefore you need to be logged in to Pinboard in order use this feature. This works the same as in the official add-on.
40 |
41 | * If you get errors when requesting data from the Pinboard API via https, these could be caused by the Privacy Badger extension. Make sure that the domain pinboard.in is fully enabled in Privacy Badger or whitelist it.
42 |
43 | Future development
44 | ------------------
45 |
46 | * Use v2 of the Pinboard API when this is available with all the necessary functionality.
47 |
48 | * Require only those permissions that are needed for the selected options (issue #8).
49 |
50 | * The Pinboard API seems to have the "popular" and "recommended" categories interchanged in the "suggest" method for tags. "Popular" are actually those taken from our own tags, contrary to what the Pinboard API docs say. This has already been reported to the Pinboard support. If they will changed this behavior, we need to adapt our code that currently swaps these categories.
51 |
52 | * Ask Pinboard author to provide a method for storing tabsets and support it in the add-on.
53 |
54 | * The PinPageComponent is much too big, and should be refactored to use child components, and objects instead of individual properties for the form fields, similar to the OptionsComponent.
55 |
56 | * Make this extension also work with Chrome (use the `chrome.*` API instead of the `browser.*` API provided by Firefox).
57 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Mozilla Public License Version 2.0
2 | ==================================
3 |
4 | 1. Definitions
5 | --------------
6 |
7 | 1.1. "Contributor"
8 | means each individual or legal entity that creates, contributes to
9 | the creation of, or owns Covered Software.
10 |
11 | 1.2. "Contributor Version"
12 | means the combination of the Contributions of others (if any) used
13 | by a Contributor and that particular Contributor's Contribution.
14 |
15 | 1.3. "Contribution"
16 | means Covered Software of a particular Contributor.
17 |
18 | 1.4. "Covered Software"
19 | means Source Code Form to which the initial Contributor has attached
20 | the notice in Exhibit A, the Executable Form of such Source Code
21 | Form, and Modifications of such Source Code Form, in each case
22 | including portions thereof.
23 |
24 | 1.5. "Incompatible With Secondary Licenses"
25 | means
26 |
27 | (a) that the initial Contributor has attached the notice described
28 | in Exhibit B to the Covered Software; or
29 |
30 | (b) that the Covered Software was made available under the terms of
31 | version 1.1 or earlier of the License, but not also under the
32 | terms of a Secondary License.
33 |
34 | 1.6. "Executable Form"
35 | means any form of the work other than Source Code Form.
36 |
37 | 1.7. "Larger Work"
38 | means a work that combines Covered Software with other material, in
39 | a separate file or files, that is not Covered Software.
40 |
41 | 1.8. "License"
42 | means this document.
43 |
44 | 1.9. "Licensable"
45 | means having the right to grant, to the maximum extent possible,
46 | whether at the time of the initial grant or subsequently, any and
47 | all of the rights conveyed by this License.
48 |
49 | 1.10. "Modifications"
50 | means any of the following:
51 |
52 | (a) any file in Source Code Form that results from an addition to,
53 | deletion from, or modification of the contents of Covered
54 | Software; or
55 |
56 | (b) any new file in Source Code Form that contains any Covered
57 | Software.
58 |
59 | 1.11. "Patent Claims" of a Contributor
60 | means any patent claim(s), including without limitation, method,
61 | process, and apparatus claims, in any patent Licensable by such
62 | Contributor that would be infringed, but for the grant of the
63 | License, by the making, using, selling, offering for sale, having
64 | made, import, or transfer of either its Contributions or its
65 | Contributor Version.
66 |
67 | 1.12. "Secondary License"
68 | means either the GNU General Public License, Version 2.0, the GNU
69 | Lesser General Public License, Version 2.1, the GNU Affero General
70 | Public License, Version 3.0, or any later versions of those
71 | licenses.
72 |
73 | 1.13. "Source Code Form"
74 | means the form of the work preferred for making modifications.
75 |
76 | 1.14. "You" (or "Your")
77 | means an individual or a legal entity exercising rights under this
78 | License. For legal entities, "You" includes any entity that
79 | controls, is controlled by, or is under common control with You. For
80 | purposes of this definition, "control" means (a) the power, direct
81 | or indirect, to cause the direction or management of such entity,
82 | whether by contract or otherwise, or (b) ownership of more than
83 | fifty percent (50%) of the outstanding shares or beneficial
84 | ownership of such entity.
85 |
86 | 2. License Grants and Conditions
87 | --------------------------------
88 |
89 | 2.1. Grants
90 |
91 | Each Contributor hereby grants You a world-wide, royalty-free,
92 | non-exclusive license:
93 |
94 | (a) under intellectual property rights (other than patent or trademark)
95 | Licensable by such Contributor to use, reproduce, make available,
96 | modify, display, perform, distribute, and otherwise exploit its
97 | Contributions, either on an unmodified basis, with Modifications, or
98 | as part of a Larger Work; and
99 |
100 | (b) under Patent Claims of such Contributor to make, use, sell, offer
101 | for sale, have made, import, and otherwise transfer either its
102 | Contributions or its Contributor Version.
103 |
104 | 2.2. Effective Date
105 |
106 | The licenses granted in Section 2.1 with respect to any Contribution
107 | become effective for each Contribution on the date the Contributor first
108 | distributes such Contribution.
109 |
110 | 2.3. Limitations on Grant Scope
111 |
112 | The licenses granted in this Section 2 are the only rights granted under
113 | this License. No additional rights or licenses will be implied from the
114 | distribution or licensing of Covered Software under this License.
115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a
116 | Contributor:
117 |
118 | (a) for any code that a Contributor has removed from Covered Software;
119 | or
120 |
121 | (b) for infringements caused by: (i) Your and any other third party's
122 | modifications of Covered Software, or (ii) the combination of its
123 | Contributions with other software (except as part of its Contributor
124 | Version); or
125 |
126 | (c) under Patent Claims infringed by Covered Software in the absence of
127 | its Contributions.
128 |
129 | This License does not grant any rights in the trademarks, service marks,
130 | or logos of any Contributor (except as may be necessary to comply with
131 | the notice requirements in Section 3.4).
132 |
133 | 2.4. Subsequent Licenses
134 |
135 | No Contributor makes additional grants as a result of Your choice to
136 | distribute the Covered Software under a subsequent version of this
137 | License (see Section 10.2) or under the terms of a Secondary License (if
138 | permitted under the terms of Section 3.3).
139 |
140 | 2.5. Representation
141 |
142 | Each Contributor represents that the Contributor believes its
143 | Contributions are its original creation(s) or it has sufficient rights
144 | to grant the rights to its Contributions conveyed by this License.
145 |
146 | 2.6. Fair Use
147 |
148 | This License is not intended to limit any rights You have under
149 | applicable copyright doctrines of fair use, fair dealing, or other
150 | equivalents.
151 |
152 | 2.7. Conditions
153 |
154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155 | in Section 2.1.
156 |
157 | 3. Responsibilities
158 | -------------------
159 |
160 | 3.1. Distribution of Source Form
161 |
162 | All distribution of Covered Software in Source Code Form, including any
163 | Modifications that You create or to which You contribute, must be under
164 | the terms of this License. You must inform recipients that the Source
165 | Code Form of the Covered Software is governed by the terms of this
166 | License, and how they can obtain a copy of this License. You may not
167 | attempt to alter or restrict the recipients' rights in the Source Code
168 | Form.
169 |
170 | 3.2. Distribution of Executable Form
171 |
172 | If You distribute Covered Software in Executable Form then:
173 |
174 | (a) such Covered Software must also be made available in Source Code
175 | Form, as described in Section 3.1, and You must inform recipients of
176 | the Executable Form how they can obtain a copy of such Source Code
177 | Form by reasonable means in a timely manner, at a charge no more
178 | than the cost of distribution to the recipient; and
179 |
180 | (b) You may distribute such Executable Form under the terms of this
181 | License, or sublicense it under different terms, provided that the
182 | license for the Executable Form does not attempt to limit or alter
183 | the recipients' rights in the Source Code Form under this License.
184 |
185 | 3.3. Distribution of a Larger Work
186 |
187 | You may create and distribute a Larger Work under terms of Your choice,
188 | provided that You also comply with the requirements of this License for
189 | the Covered Software. If the Larger Work is a combination of Covered
190 | Software with a work governed by one or more Secondary Licenses, and the
191 | Covered Software is not Incompatible With Secondary Licenses, this
192 | License permits You to additionally distribute such Covered Software
193 | under the terms of such Secondary License(s), so that the recipient of
194 | the Larger Work may, at their option, further distribute the Covered
195 | Software under the terms of either this License or such Secondary
196 | License(s).
197 |
198 | 3.4. Notices
199 |
200 | You may not remove or alter the substance of any license notices
201 | (including copyright notices, patent notices, disclaimers of warranty,
202 | or limitations of liability) contained within the Source Code Form of
203 | the Covered Software, except that You may alter any license notices to
204 | the extent required to remedy known factual inaccuracies.
205 |
206 | 3.5. Application of Additional Terms
207 |
208 | You may choose to offer, and to charge a fee for, warranty, support,
209 | indemnity or liability obligations to one or more recipients of Covered
210 | Software. However, You may do so only on Your own behalf, and not on
211 | behalf of any Contributor. You must make it absolutely clear that any
212 | such warranty, support, indemnity, or liability obligation is offered by
213 | You alone, and You hereby agree to indemnify every Contributor for any
214 | liability incurred by such Contributor as a result of warranty, support,
215 | indemnity or liability terms You offer. You may include additional
216 | disclaimers of warranty and limitations of liability specific to any
217 | jurisdiction.
218 |
219 | 4. Inability to Comply Due to Statute or Regulation
220 | ---------------------------------------------------
221 |
222 | If it is impossible for You to comply with any of the terms of this
223 | License with respect to some or all of the Covered Software due to
224 | statute, judicial order, or regulation then You must: (a) comply with
225 | the terms of this License to the maximum extent possible; and (b)
226 | describe the limitations and the code they affect. Such description must
227 | be placed in a text file included with all distributions of the Covered
228 | Software under this License. Except to the extent prohibited by statute
229 | or regulation, such description must be sufficiently detailed for a
230 | recipient of ordinary skill to be able to understand it.
231 |
232 | 5. Termination
233 | --------------
234 |
235 | 5.1. The rights granted under this License will terminate automatically
236 | if You fail to comply with any of its terms. However, if You become
237 | compliant, then the rights granted under this License from a particular
238 | Contributor are reinstated (a) provisionally, unless and until such
239 | Contributor explicitly and finally terminates Your grants, and (b) on an
240 | ongoing basis, if such Contributor fails to notify You of the
241 | non-compliance by some reasonable means prior to 60 days after You have
242 | come back into compliance. Moreover, Your grants from a particular
243 | Contributor are reinstated on an ongoing basis if such Contributor
244 | notifies You of the non-compliance by some reasonable means, this is the
245 | first time You have received notice of non-compliance with this License
246 | from such Contributor, and You become compliant prior to 30 days after
247 | Your receipt of the notice.
248 |
249 | 5.2. If You initiate litigation against any entity by asserting a patent
250 | infringement claim (excluding declaratory judgment actions,
251 | counter-claims, and cross-claims) alleging that a Contributor Version
252 | directly or indirectly infringes any patent, then the rights granted to
253 | You by any and all Contributors for the Covered Software under Section
254 | 2.1 of this License shall terminate.
255 |
256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257 | end user license agreements (excluding distributors and resellers) which
258 | have been validly granted by You or Your distributors under this License
259 | prior to termination shall survive termination.
260 |
261 | ************************************************************************
262 | * *
263 | * 6. Disclaimer of Warranty *
264 | * ------------------------- *
265 | * *
266 | * Covered Software is provided under this License on an "as is" *
267 | * basis, without warranty of any kind, either expressed, implied, or *
268 | * statutory, including, without limitation, warranties that the *
269 | * Covered Software is free of defects, merchantable, fit for a *
270 | * particular purpose or non-infringing. The entire risk as to the *
271 | * quality and performance of the Covered Software is with You. *
272 | * Should any Covered Software prove defective in any respect, You *
273 | * (not any Contributor) assume the cost of any necessary servicing, *
274 | * repair, or correction. This disclaimer of warranty constitutes an *
275 | * essential part of this License. No use of any Covered Software is *
276 | * authorized under this License except under this disclaimer. *
277 | * *
278 | ************************************************************************
279 |
280 | ************************************************************************
281 | * *
282 | * 7. Limitation of Liability *
283 | * -------------------------- *
284 | * *
285 | * Under no circumstances and under no legal theory, whether tort *
286 | * (including negligence), contract, or otherwise, shall any *
287 | * Contributor, or anyone who distributes Covered Software as *
288 | * permitted above, be liable to You for any direct, indirect, *
289 | * special, incidental, or consequential damages of any character *
290 | * including, without limitation, damages for lost profits, loss of *
291 | * goodwill, work stoppage, computer failure or malfunction, or any *
292 | * and all other commercial damages or losses, even if such party *
293 | * shall have been informed of the possibility of such damages. This *
294 | * limitation of liability shall not apply to liability for death or *
295 | * personal injury resulting from such party's negligence to the *
296 | * extent applicable law prohibits such limitation. Some *
297 | * jurisdictions do not allow the exclusion or limitation of *
298 | * incidental or consequential damages, so this exclusion and *
299 | * limitation may not apply to You. *
300 | * *
301 | ************************************************************************
302 |
303 | 8. Litigation
304 | -------------
305 |
306 | Any litigation relating to this License may be brought only in the
307 | courts of a jurisdiction where the defendant maintains its principal
308 | place of business and such litigation shall be governed by laws of that
309 | jurisdiction, without reference to its conflict-of-law provisions.
310 | Nothing in this Section shall prevent a party's ability to bring
311 | cross-claims or counter-claims.
312 |
313 | 9. Miscellaneous
314 | ----------------
315 |
316 | This License represents the complete agreement concerning the subject
317 | matter hereof. If any provision of this License is held to be
318 | unenforceable, such provision shall be reformed only to the extent
319 | necessary to make it enforceable. Any law or regulation which provides
320 | that the language of a contract shall be construed against the drafter
321 | shall not be used to construe this License against a Contributor.
322 |
323 | 10. Versions of the License
324 | ---------------------------
325 |
326 | 10.1. New Versions
327 |
328 | Mozilla Foundation is the license steward. Except as provided in Section
329 | 10.3, no one other than the license steward has the right to modify or
330 | publish new versions of this License. Each version will be given a
331 | distinguishing version number.
332 |
333 | 10.2. Effect of New Versions
334 |
335 | You may distribute the Covered Software under the terms of the version
336 | of the License under which You originally received the Covered Software,
337 | or under the terms of any subsequent version published by the license
338 | steward.
339 |
340 | 10.3. Modified Versions
341 |
342 | If you create software not governed by this License, and you want to
343 | create a new license for such software, you may create and use a
344 | modified version of this License if you rename the license and remove
345 | any references to the name of the license steward (except to note that
346 | such modified license differs from this License).
347 |
348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary
349 | Licenses
350 |
351 | If You choose to distribute Source Code Form that is Incompatible With
352 | Secondary Licenses under the terms of this version of the License, the
353 | notice described in Exhibit B of this License must be attached.
354 |
355 | Exhibit A - Source Code Form License Notice
356 | -------------------------------------------
357 |
358 | This Source Code Form is subject to the terms of the Mozilla Public
359 | License, v. 2.0. If a copy of the MPL was not distributed with this
360 | file, You can obtain one at http://mozilla.org/MPL/2.0/.
361 |
362 | If it is not possible or desirable to put the notice in a particular
363 | file, then You may include the notice in a location (such as a LICENSE
364 | file in a relevant directory) where a recipient would be likely to look
365 | for such a notice.
366 |
367 | You may add additional accurate notices of copyright ownership.
368 |
369 | Exhibit B - "Incompatible With Secondary Licenses" Notice
370 | ---------------------------------------------------------
371 |
372 | This Source Code Form is "Incompatible With Secondary Licenses", as
373 | defined by the Mozilla Public License, v. 2.0.
374 |
--------------------------------------------------------------------------------
/PRIVACY.md:
--------------------------------------------------------------------------------
1 | Privacy Policy for the Pinboard-Pin Add-On
2 | ==========================================
3 |
4 | This add-on communicates with the [Pinboard](https://pinboard.in/) service using the [Pinboard API](https://pinboard.in/api) for the purpose of storing and updating bookmarks in your personal Pinboard account.
5 |
6 | In order to access your personal Pinboard account, your personal Pinboard API token is requested by the add-on and cached locally until you log out using the add-on. Your Pinboard password is not requested, accessed or stored by the add-on.
7 |
8 | In order to provide suggestions for tagging bookmarks, the add-on retrieves your tags stored in your personal Pinboard account using the Pinboard API and caches these tags locally.
9 |
10 | The data sent to the Pinboard service are the URL of the bookmarked link, its title, description, tags, and privacy and read status on Pinboard.
11 |
12 | If you activate the option "always check and show whether pages have been bookmarked" (which is deactivated by default), then the add-on checks for every tab whether it has been already bookmarked. For this purpose, it sends the URL of the tab to the Pinboard service using the Pinboard API.
13 |
14 | Please also read the [Pinboard privacy policy](https://pinboard.in/privacy/) for information on the privacy police of the Pinboard service itself.
15 |
16 | The author of this add-on is not affiliated with the Pinboard service in any way and does not take any responsibility for how the service handles your bookmarks.
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Pinboard Pin Web Extension for Firefox
2 | --------------------------------------
3 |
4 | Pinboard Pin is a modern web extension for pinning pages on [Pinboard](https://pinboard.in) with Firefox.
5 |
6 | Pinboard is a fast, no-nonsense bookmarking site for people who value privacy and speed. Note that while the Pinboard Pin extension is provided by its author as free and open source software, Pinboard is a separate, paid service and you need to sign up for an account in order to use it. The author of Pinboard Pin is not affiliated with the provider of the Pinboard service. For any questions regarding the Pinboard service itself, please contact the Pinboard support.
7 |
8 | This extension pretty much replicates the functionality of the [Pinboard Plus](https://github.com/clvrobj/Pinboard-Plus) extension that has been created for the Chrome browser, but it has been rewritten from scratch to support Firefox using the modern [Angular](https://angular.io/) framework instead of a mix of the older [AngularJS](https://angularjs.org/), [jQuery](https://jquery.com/) and [Underscore](http://underscorejs.org/) libraries used by Pinboard Plus. This rewrite was also intended as a proof-of-concept that modern Angular is a viable platform for building web extensions.
9 |
10 | The current version has been tested with Firefox 80 for Windows and Linux.
11 |
12 | Features
13 | --------
14 |
15 | * Icon that changes its color to show whether the current page has been bookmarked in Pinboard.
16 | * Save a new bookmark for the current page in Pinboard, adding description and tags in a popup dialog.
17 | * Update and delete the bookmark for the current page in Pinboard from the popup.
18 | * Automatic creation of a description from a selected text on the page or using an existing meta tag on the page.
19 | * Enter or update tags using automatic suggestions in the popup dialog.
20 | * Use a keyboard shortcut (Alt + P) to open the popup dialog.
21 | * Use the context menu to open the popup dialog for the current page or to quickly save any link on the page.
22 | * Configurable dark mode for the popup dialog.
23 |
24 | Installation
25 | ------------
26 |
27 | You can install the extension using the [Mozilla Add-ons](https://addons.mozilla.org/de/firefox/addon/pinboard-pin/) page.
28 |
29 | Notes
30 | -----
31 |
32 | Note that you must explicitly enable the option for displaying whether the page has already been saved on Pinboard, because this will send the URL of the page to the Pinboard server for every page. Therefore this feature is also automatically disabled in "incognito mode".
33 |
34 | Also note that if you are using the Privacy Badger extension and Pinboard Pin shows an error when accessing Pinboard, make sure that the domain pinboard.in is not blocked in the filter settings of Privacy Badger, or simply put in on the whitelist of Privacy Badger.
35 |
36 | Development
37 | -----------
38 |
39 | * Follow the instructions outlined in [DEVELOP.md](https://github.com/cito/Pinboard-Pin/blob/master/DEVELOP.md) if you want to build this extension on your own or run it in development mode.
40 | * Read my blog post [Web Extensions made with Angular](https://cito.github.io/blog/web-ext-with-angular/) to learn more about how and why this extension has been created.
41 | * Contact the author, open GitHub issues or send in pull requests to contribute.
42 |
43 | Author
44 | ------
45 |
46 | * [Christoph Zwerschke](https://github.com/cito)
47 |
48 | Some Screenshots
49 | ----------------
50 |
51 | Saving a page with Pinboard Pin:
52 |
53 | 
54 |
55 | Changing the Pinboard Pin settings:
56 |
57 | 
58 |
59 | Pinboard Pin also supports dark mode:
60 |
61 | 
62 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "pinboard-pin": {
7 | "projectType": "application",
8 | "schematics": {
9 | "@schematics/angular:component": {
10 | "style": "scss"
11 | },
12 | "@schematics/angular:application": {
13 | "strict": true
14 | }
15 | },
16 | "root": "",
17 | "sourceRoot": "src",
18 | "prefix": "app",
19 | "architect": {
20 | "build": {
21 | "builder": "@angular-devkit/build-angular:browser",
22 | "options": {
23 | "outputPath": "dist",
24 | "index": "src/index.html",
25 | "main": "src/main.ts",
26 | "polyfills": "src/polyfills.ts",
27 | "tsConfig": "tsconfig.app.json",
28 | "inlineStyleLanguage": "scss",
29 | "assets": [
30 | "src/img",
31 | "src/js",
32 | "src/manifest.json"
33 | ],
34 | "styles": [
35 | "src/styles.scss"
36 | ],
37 | "scripts": [],
38 | "vendorChunk": true,
39 | "extractLicenses": false,
40 | "buildOptimizer": false,
41 | "sourceMap": true,
42 | "optimization": false,
43 | "namedChunks": true
44 | },
45 | "configurations": {
46 | "production": {
47 | "budgets": [
48 | {
49 | "type": "initial",
50 | "maximumWarning": "500kb",
51 | "maximumError": "1mb"
52 | },
53 | {
54 | "type": "anyComponentStyle",
55 | "maximumWarning": "2kb",
56 | "maximumError": "4kb"
57 | }
58 | ],
59 | "optimization": {
60 | "scripts": true,
61 | "styles": {
62 | "minify": true,
63 | "inlineCritical": false
64 | },
65 | "fonts": true
66 | },
67 | "outputHashing": "all",
68 | "sourceMap": false,
69 | "namedChunks": false,
70 | "extractLicenses": true,
71 | "vendorChunk": false,
72 | "buildOptimizer": true,
73 | "fileReplacements": [
74 | {
75 | "replace": "src/environments/environment.ts",
76 | "with": "src/environments/environment.prod.ts"
77 | }
78 | ]
79 | }
80 | }
81 | },
82 | "serve": {
83 | "builder": "@angular-devkit/build-angular:dev-server",
84 | "options": {
85 | "buildTarget": "pinboard-pin:build"
86 | },
87 | "configurations": {
88 | "production": {
89 | "buildTarget": "pinboard-pin:build:production"
90 | }
91 | }
92 | },
93 | "extract-i18n": {
94 | "builder": "@angular-devkit/build-angular:extract-i18n",
95 | "options": {
96 | "buildTarget": "pinboard-pin:build"
97 | }
98 | },
99 | "lint": {
100 | "builder": "@angular-devkit/build-angular:tslint",
101 | "options": {
102 | "tsConfig": [
103 | "tsconfig.app.json"
104 | ],
105 | "exclude": []
106 | }
107 | }
108 | }
109 | }
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "pinboard-pin",
3 | "version": "0.4.3",
4 | "license": "MIT",
5 | "scripts": {
6 | "build": "ng build",
7 | "build:prod": "ng build --configuration production --source-map=false --output-hashing=none",
8 | "build:ext": "web-ext build --source-dir=dist --artifacts-dir=.",
9 | "build:zip": "npm run build:prod && npm run build:ext",
10 | "lint": "tslint \"src/**/*.ts\"",
11 | "test": "web-ext run --source-dir=dist --firefox=\"C:/Program Files/Mozilla Firefox/firefox.exe\"",
12 | "test:dev": "web-ext run --source-dir=dist --firefox=\"C:/Program Files/Firefox Developer Edition/firefox.exe\"",
13 | "test:nightly": "web-ext run --source-dir=dist --firefox=\"C:/Program Files/Nightly/firefox.exe\""
14 | },
15 | "private": true,
16 | "dependencies": {
17 | "@angular/common": "^17.3.5",
18 | "@angular/compiler": "^17.3.5",
19 | "@angular/core": "^17.3.5",
20 | "@angular/forms": "^17.3.5",
21 | "@angular/platform-browser": "^17.3.5",
22 | "@angular/platform-browser-dynamic": "^17.3.5",
23 | "@angular/router": "^17.3.5",
24 | "rxjs": "^7.8.1",
25 | "tslib": "^2.6.2",
26 | "zone.js": "~0.14.4"
27 | },
28 | "devDependencies": {
29 | "@angular-devkit/build-angular": "^17.3.5",
30 | "@angular/cli": "^17.3.5",
31 | "@angular/compiler-cli": "^17.3.5",
32 | "@angular/language-service": "^17.3.5",
33 | "@angular-eslint/builder": "^17.3.0",
34 | "@angular-eslint/eslint-plugin": "^17.3.0",
35 | "@angular-eslint/eslint-plugin-template": "^17.3.0",
36 | "@angular-eslint/schematics": "^17.3.0",
37 | "@angular-eslint/template-parser": "^17.3.0",
38 | "@types/node": "^20.12.7",
39 | "@typescript-eslint/eslint-plugin": "^7.7.0",
40 | "@typescript-eslint/parser": "^7.7.0",
41 | "@types/firefox-webext-browser": "^120.0.3",
42 | "eslint": "^8.57.0",
43 | "typescript": "^5.4.5",
44 | "web-ext": "^7.11.0"
45 | }
46 | }
--------------------------------------------------------------------------------
/screenshots/pinboard-pin-dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cito/Pinboard-Pin/13efee4147e3983e53c9b6dca641a2550bc54892/screenshots/pinboard-pin-dark.png
--------------------------------------------------------------------------------
/screenshots/pinboard-pin-light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cito/Pinboard-Pin/13efee4147e3983e53c9b6dca641a2550bc54892/screenshots/pinboard-pin-light.png
--------------------------------------------------------------------------------
/screenshots/pinboard-pin-settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cito/Pinboard-Pin/13efee4147e3983e53c9b6dca641a2550bc54892/screenshots/pinboard-pin-settings.png
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 |
4 | // Root component of the application
5 |
6 | @Component({
7 | selector: 'app-root',
8 | template: '
You must log in to Pinboard first using the API token 6 | that you can find on your 7 | Pinboard password page.
8 | 9 | 26 | 27 |{{error}}
118 | 119 | 126 | 127 |' + 169 | this.description.slice(0, 3200 - 25) + ''; 170 | } 171 | this.keywords = content.keywords; 172 | this.tags = null; 173 | this.unshared = this.options.unshared; 174 | this.toread = this.options.toread; 175 | this.retry = true; 176 | this.suggested = this.popular = null; 177 | // query both page data and suggested tags 178 | this.pinboard.getAndSuggest(this.url).subscribe( 179 | data => this.setData(data), 180 | error => this.logError( 181 | 'Cannot check this page on Pinboard.', error.toString())); 182 | } else { 183 | this.logError('Can only pin normal web pages.', 184 | 'Cannot get the URL of the page'); 185 | } 186 | } 187 | 188 | // receive page data and suggested tags from parallel queries 189 | setData(data: any): void { 190 | if (data.posts && data.posts.length) { 191 | this.date = data?.date; 192 | const post = data.posts[0]; 193 | this.url = post.href; 194 | this.title = post.description; 195 | this.description = post.extended; 196 | this.tags = post.tags; 197 | this.unshared = post.shared !== 'yes'; 198 | this.toread = post.toread === 'yes'; 199 | this.update = true; 200 | // set browser icon to saved state 201 | browser.tabs.query({ url: this.url }).then(tabs => { 202 | for (const tab of tabs) { 203 | this.icon.setIcon(tab.id, true); 204 | } 205 | }, 206 | error => console.error(error.toString())); 207 | } 208 | // Note: "popular" and "recommended" are interchanged in Pinboard 209 | if (data.popular) { 210 | this.suggested = data.popular; 211 | } 212 | if (this.options.popular && data.recommended) { 213 | this.popular = data.recommended; 214 | } 215 | this.pinboard.cachedTags().subscribe(tags => { 216 | this.allTags = tags; 217 | if (this.tags) { 218 | this.tags.trim(); 219 | this.savedTags = this.tags; 220 | this.tags += ' '; 221 | } else { 222 | this.savedTags = null; 223 | } 224 | this.completions = null; 225 | this.setReady(); 226 | }); 227 | } 228 | 229 | // set form as ready for input 230 | setReady(): void { 231 | this.ready = true; 232 | // wait until inputs have been enabled, then focus 233 | timer(0).subscribe(() => { 234 | const focus = this.url ? (this.title ? ( 235 | this.tags && !this.description ? 236 | 'description' : 'tags') : 'title') : 'url'; 237 | this.eref.nativeElement.querySelector('#' + focus).focus(); 238 | }); 239 | } 240 | 241 | // check whether the given tags have already been added 242 | hasTags(tags: string | string[]): boolean { 243 | if (!this.tags) { 244 | return false; 245 | } 246 | if (!Array.isArray(tags)) { 247 | tags = [tags as string]; 248 | } 249 | const allTags = this.tags.split(' ').filter(tag => !!tag); 250 | return (tags as string[]).every(tag => allTags.includes(tag)); 251 | } 252 | 253 | // add the given tags if they have not already been added, otherwise remove 254 | addTags(tags: string | string[]): void { 255 | if (!Array.isArray(tags)) { 256 | tags = [tags as string]; 257 | } 258 | let allTags = (this.tags || '').split(' ').filter(tag => !!tag); 259 | const newTags = (tags as string[]).filter(tag => !allTags.includes(tag)); 260 | if (newTags.length) { // some tags are new 261 | allTags.push(...newTags); // add these tags 262 | } else { // all tags have already been added, remove these tags again 263 | allTags = allTags.filter(tag => !(tags as string[]).includes(tag)); 264 | } 265 | this.tags = allTags.join(' '); 266 | } 267 | 268 | // this method is called when keys have been pressed down in the tabs field 269 | tagsKeyDown(event: any): boolean { 270 | if (!this.ready || !this.tagsFocus || !this.completions) { 271 | return true; 272 | } 273 | // Firefox reacts to some of our control keys as well, so to prevent this 274 | // from happening, we have to listen here before the key has been pressed 275 | let control = true; 276 | switch (event.code) { 277 | case 'Home': 278 | this.tagSelected = 0; 279 | break; 280 | case 'End': 281 | this.tagSelected = this.completions.length - 1; 282 | break; 283 | case 'ArrowDown': 284 | if (this.tagSelected < this.completions.length - 1) { 285 | ++this.tagSelected; 286 | } 287 | break; 288 | case 'ArrowUp': 289 | if (this.tagSelected > 0) { 290 | --this.tagSelected; 291 | } 292 | break; 293 | case 'Enter': 294 | case 'Tab': 295 | case 'ArrowRight': 296 | const tag = this.completions[this.tagSelected]; 297 | let value = event.target.value; 298 | const words = value.split(' '); 299 | if (words.length) { 300 | words.pop(); 301 | } 302 | if (!words.includes(tag)) { 303 | words.push(tag); 304 | value = words.join(' ') + ' '; 305 | this.tagsChanged(value); 306 | this.tags = value; 307 | } 308 | break; 309 | default: 310 | control = false; 311 | } 312 | return !control; 313 | } 314 | 315 | // this method is called when keys have been released in the tabs field 316 | tagsKeyUp(event: any): boolean { 317 | // the field value is changed after the key has been pressed, 318 | // so this is the right moment for checking for value changes 319 | if (this.ready && this.tagsFocus) { 320 | this.tagsSubject.next(event.target.value); 321 | } 322 | return true; 323 | } 324 | 325 | // this method is called with debounce when tags have changed 326 | // it must then determine the list of tag completions 327 | tagsChanged(tags: string): void { 328 | const words = tags.replace(',', ' ').split(' '); 329 | let word = words.length ? words.pop() : null; 330 | const allTags = this.allTags; 331 | const matches: [string, number][] = []; 332 | const alpha = this.options.alpha; 333 | if (word) { 334 | word = word.toLowerCase(); 335 | for (const tag in allTags) { 336 | if (allTags.hasOwnProperty(tag)) { 337 | if (tag.toLowerCase().startsWith(word) && !words.includes(tag)) { 338 | matches.push([tag, alpha ? 0 : allTags[tag]]); 339 | } 340 | } 341 | } 342 | } 343 | // sort matching tags by decreasing frequency 344 | matches.sort((a: [string, number], b: [string, number]) => 345 | b[1] - a[1] || a[0].localeCompare(b[0])); 346 | matches.splice(maxCompletions); 347 | const completions: string[] = matches.map(a => a[0]).reverse(); 348 | if (completions.length) { 349 | const oldCompletions = this.completions; 350 | if (!oldCompletions || completions.length !== oldCompletions.length || 351 | completions.some((tag, i) => 352 | completions[i] !== oldCompletions[i])) { 353 | this.completions = completions; 354 | this.tagSelected = completions.length - 1; 355 | } 356 | } else { 357 | this.completions = null; 358 | } 359 | } 360 | 361 | // this method is called when a tag completion was clicked 362 | selectCompletion(tag: string): boolean { 363 | let value = this.tags || ''; 364 | const words = value.split(' '); 365 | if (words.length) { 366 | words.pop(); 367 | } 368 | if (!words.includes(tag)) { 369 | words.push(tag); 370 | value = words.join(' ') + ' '; 371 | this.tagsChanged(value); 372 | this.tags = value; 373 | } 374 | return false; 375 | } 376 | 377 | // delete the current bookmark 378 | remove(): boolean { 379 | if (this.ready && this.update && this.url) { 380 | this.pinboard.delete(this.url).subscribe( 381 | () => { 382 | // update the tags in the cache 383 | const savedTags = this.savedTags ? this.savedTags.split(' ') : []; 384 | this.pinboard.updateTagCache([], savedTags).pipe(finalize( 385 | // set the browser icon to unsaved state 386 | () => browser.tabs.query({ url: this.url }).then(tabs => { 387 | for (const tab of tabs) { 388 | this.icon.setIcon(tab.id, false); 389 | } 390 | this.cancel(); 391 | }, error => { 392 | console.error(error.toString()); 393 | this.cancel(); 394 | }))).subscribe(); 395 | }, 396 | error => { 397 | this.logError('Sorry, could not remove this page from Pinboard', 398 | error.toString()); 399 | }); 400 | } 401 | return false; 402 | } 403 | 404 | // reset error message 405 | reset(): boolean { 406 | this.error = null; 407 | return false; 408 | } 409 | 410 | // submit form 411 | submit(form: NgForm): boolean { 412 | if (form.valid) { 413 | this.save(form.value); 414 | } 415 | return false; 416 | } 417 | 418 | // save page to Pinboard 419 | save(value: Post): void { 420 | value.url = (value.url || '').trim(); 421 | value.title = (value.title || '').trim(); 422 | if (!value.url || !value.title) { 423 | return; 424 | } 425 | value.description = (value.description || '').trim() || null; 426 | // clean up tags, maximum of 100 tags with 255 chars each 427 | const tags = value.tags ? value.tags.split(' ').filter( 428 | tag => !!tag).slice(0, 100).map(tag => tag.slice(0, 255)) : []; 429 | value.tags = tags.join(' '); 430 | const savedTags = this.savedTags ? this.savedTags.split(' ') : []; 431 | this.pinboard.save(value).subscribe( 432 | error => { 433 | if (error) { 434 | this.logError('Sorry, could not save this page to Pinboard', 435 | error); 436 | } else { 437 | // update the tags in the cache 438 | this.pinboard.updateTagCache(tags, savedTags).pipe(finalize( 439 | // set the browser icon to saved state 440 | () => browser.tabs.query({ url: this.url }).then(tabs => { 441 | for (const tab of tabs) { 442 | this.icon.setIcon(tab.id, true); 443 | } 444 | this.cancel(); 445 | }, error => { 446 | console.error(error.toString()); 447 | this.cancel(); 448 | }))).subscribe(); 449 | } 450 | }, 451 | error => { 452 | this.logError('Sorry, could not save this page to Pinboard', 453 | error.toString()); 454 | }); 455 | } 456 | 457 | // save current tabs as tab set to Pinboard 458 | saveTabs(): void { 459 | browser.tabs.query({ windowType: 'normal', url: '*://*/*' }).then( 460 | tabs => { 461 | const wTabs = {}; 462 | for (const tab of tabs) { 463 | const wId = tab.windowId; 464 | if (!wTabs[wId]) { 465 | wTabs[wId] = {}; 466 | } 467 | wTabs[wId][tab.index] = { title: tab.title, url: tab.url }; 468 | } 469 | const windows = Object.keys(wTabs).map( 470 | wId => Object.keys(wTabs[wId]).map( 471 | index => wTabs[wId][index])); 472 | if (windows.length) { 473 | const data = { 474 | browser: 'ffox', windows: windows, 475 | }; 476 | this.pinboard.saveTabs(data).subscribe(() => { 477 | this.cancel(); 478 | }, error => { 479 | this.logError( 480 | 'Sorry, could not save this tab set to Pinboard.', 481 | error.toString()); 482 | }); 483 | } 484 | }); 485 | } 486 | 487 | // navigate to options 488 | settings(): void { 489 | // store a note that we are showing on a popup page 490 | this.storage.setInfo('options.page', 'popup'); 491 | this.router.navigate(['/options']); 492 | } 493 | 494 | // log out from Pinboard 495 | logOut(): void { 496 | this.pinboard.forgetToken().subscribe( 497 | () => this.router.navigate(['/login'])); 498 | } 499 | 500 | // show error message and log it on the console 501 | logError(errmsg, logmsg): void { 502 | if (errmsg) { 503 | console.error(logmsg || errmsg); 504 | } 505 | this.error = errmsg; 506 | } 507 | 508 | pinboardLink(page): boolean { 509 | if (page && page.indexOf('~') >= 0) { 510 | this.pinboard.userName.subscribe( 511 | name => this.pinboardLink(page.replace('~', 'u:' + name))); 512 | } else { 513 | let url = pinboardPage; 514 | if (page) { 515 | url += page; 516 | } 517 | browser.tabs.create({ url: url }); 518 | this.cancel(); 519 | } 520 | return false; 521 | } 522 | 523 | // close the whole popup 524 | cancel(): void { 525 | window.close(); 526 | } 527 | 528 | } 529 | -------------------------------------------------------------------------------- /src/app/storage.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | import { Observable, from as ObservableFrom } from 'rxjs'; 4 | import { map } from 'rxjs/operators'; 5 | 6 | export interface Options { 7 | ping: boolean; // check whether pages are bookmarked 8 | unshared: boolean; // add as private by default 9 | toread: boolean; // add as to read by default 10 | meta: boolean; // parse meta elements 11 | selection: boolean; // use selected text 12 | blockquote: boolean; // wrap as block quote 13 | alpha: boolean; // sort alphabetically 14 | popular: boolean; // show popular tags 15 | menu: boolean; // add entry to context menu 16 | dark: boolean; // use dark mode 17 | } 18 | 19 | const defaultOptions: Options = { 20 | ping: false, 21 | unshared: false, 22 | toread: false, 23 | meta: true, 24 | selection: true, 25 | blockquote: false, 26 | alpha: false, 27 | popular: true, 28 | menu: false, 29 | dark: null, 30 | }; 31 | 32 | 33 | // Wrapper around the browser local storage for the web extension, 34 | // using Observables instead of Promises for flexibility and consistency. 35 | 36 | @Injectable() 37 | export class StorageService { 38 | 39 | private storage = browser.storage.local; // needs "storage" permission 40 | 41 | private readonly info: Object; 42 | 43 | constructor() { 44 | this.info = {}; // for various info shared via this service 45 | } 46 | 47 | // get keys from local storage as an Observable 48 | // when only one key is requested, only its value is returned 49 | get(keys: string | string[] | null): Observable