From 23e19b48d9da685b5ca00539ae08e176114485d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Tue, 23 Feb 2021 05:02:19 +0200 Subject: [PATCH] First commit --- CC0 | 116 ++++++++++++++++++++++++++++++++++++++++ background.js | 75 ++++++++++++++++++++++++++ icons/error-32.png | Bin 0 -> 426 bytes icons/error-48.png | Bin 0 -> 524 bytes icons/error-96.png | Bin 0 -> 875 bytes icons/icon-32.png | Bin 0 -> 397 bytes icons/icon-48.png | Bin 0 -> 497 bytes icons/icon-96.png | Bin 0 -> 780 bytes icons/processing-32.png | Bin 0 -> 503 bytes icons/processing-48.png | Bin 0 -> 653 bytes icons/processing-96.png | Bin 0 -> 1092 bytes manifest.json | 31 +++++++++++ 12 files changed, 222 insertions(+) create mode 100644 CC0 create mode 100644 background.js create mode 100644 icons/error-32.png create mode 100644 icons/error-48.png create mode 100644 icons/error-96.png create mode 100644 icons/icon-32.png create mode 100644 icons/icon-48.png create mode 100644 icons/icon-96.png create mode 100644 icons/processing-32.png create mode 100644 icons/processing-48.png create mode 100644 icons/processing-96.png create mode 100644 manifest.json diff --git a/CC0 b/CC0 new file mode 100644 index 0000000..670154e --- /dev/null +++ b/CC0 @@ -0,0 +1,116 @@ +CC0 1.0 Universal + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator and +subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for the +purpose of contributing to a commons of creative, cultural and scientific +works ("Commons") that the public can reliably and without fear of later +claims of infringement build upon, modify, incorporate in other works, reuse +and redistribute as freely as possible in any form whatsoever and for any +purposes, including without limitation commercial purposes. These owners may +contribute to the Commons to promote the ideal of a free culture and the +further production of creative, cultural and scientific works, or to gain +reputation or greater distribution for their Work in part through the use and +efforts of others. + +For these and/or other purposes and motivations, and without any expectation +of additional consideration or compensation, the person associating CC0 with a +Work (the "Affirmer"), to the extent that he or she is an owner of Copyright +and Related Rights in the Work, voluntarily elects to apply CC0 to the Work +and publicly distribute the Work under its terms, with knowledge of his or her +Copyright and Related Rights in the Work and the meaning and intended legal +effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not limited +to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, communicate, + and translate a Work; + + ii. moral rights retained by the original author(s) and/or performer(s); + + iii. publicity and privacy rights pertaining to a person's image or likeness + depicted in a Work; + + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + + v. rights protecting the extraction, dissemination, use and reuse of data in + a Work; + + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation thereof, + including any amended or successor version of such directive); and + + vii. other similar, equivalent or corresponding rights throughout the world + based on applicable law or treaty, and any national implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention of, +applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and +unconditionally waives, abandons, and surrenders all of Affirmer's Copyright +and Related Rights and associated claims and causes of action, whether now +known or unknown (including existing as well as future claims and causes of +action), in the Work (i) in all territories worldwide, (ii) for the maximum +duration provided by applicable law or treaty (including future time +extensions), (iii) in any current or future medium and for any number of +copies, and (iv) for any purpose whatsoever, including without limitation +commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes +the Waiver for the benefit of each member of the public at large and to the +detriment of Affirmer's heirs and successors, fully intending that such Waiver +shall not be subject to revocation, rescission, cancellation, termination, or +any other legal or equitable action to disrupt the quiet enjoyment of the Work +by the public as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason be +judged legally invalid or ineffective under applicable law, then the Waiver +shall be preserved to the maximum extent permitted taking into account +Affirmer's express Statement of Purpose. In addition, to the extent the Waiver +is so judged Affirmer hereby grants to each affected person a royalty-free, +non transferable, non sublicensable, non exclusive, irrevocable and +unconditional license to exercise Affirmer's Copyright and Related Rights in +the Work (i) in all territories worldwide, (ii) for the maximum duration +provided by applicable law or treaty (including future time extensions), (iii) +in any current or future medium and for any number of copies, and (iv) for any +purpose whatsoever, including without limitation commercial, advertising or +promotional purposes (the "License"). The License shall be deemed effective as +of the date CC0 was applied by Affirmer to the Work. Should any part of the +License for any reason be judged legally invalid or ineffective under +applicable law, such partial invalidity or ineffectiveness shall not +invalidate the remainder of the License, and in such case Affirmer hereby +affirms that he or she will not (i) exercise any of his or her remaining +Copyright and Related Rights in the Work or (ii) assert any associated claims +and causes of action with respect to the Work, in either case contrary to +Affirmer's express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + + b. Affirmer offers the Work as-is and makes no representations or warranties + of any kind concerning the Work, express, implied, statutory or otherwise, + including without limitation warranties of title, merchantability, fitness + for a particular purpose, non infringement, or the absence of latent or + other defects, accuracy, or the present or absence of errors, whether or not + discoverable, all to the greatest extent permissible under applicable law. + + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without limitation + any person's Copyright and Related Rights in the Work. Further, Affirmer + disclaims responsibility for obtaining any necessary consents, permissions + or other rights required for any use of the Work. + + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to this + CC0 or use of the Work. + +For more information, please see + diff --git a/background.js b/background.js new file mode 100644 index 0000000..3957283 --- /dev/null +++ b/background.js @@ -0,0 +1,75 @@ +'use strict'; +let bookmarkingTabs = false; + +function createFolder(callback) { + chrome.bookmarks.create({'title': 'Autobookmarked Tabs'}, function(folder) { + chrome.storage.local.set({'bookmarksFolder': folder.id}); + callback(folder.id); + }); +} + +function getOrCreateFolder(callback) { + chrome.storage.local.get('bookmarksFolder', function (result) { + if ('bookmarksFolder' in result) { + let id = result.bookmarksFolder; + chrome.bookmarks.get(id, function(result) { + if (chrome.runtime.lastError) { + // Bookmark id not valid, create new one + createFolder(callback); + } else { + callback(id); + } + }); + } else { + createFolder(callback); + } + }); +} + +function setActionStatus(title, imageset, callback) { + chrome.browserAction.setTitle({title: title}, function() { + chrome.browserAction.setIcon({path: { + '32': 'icons/' + imageset + '-32.png', + '48': 'icons/' + imageset + '-48.png', + '96': 'icons/' + imageset + '-96.png' + }}, callback); + }); +} + +function bookmarkTabs() { + if (bookmarkingTabs) { + return; + } + + bookmarkingTabs = true; + + let now = new Date(); + let dateString = [now.getFullYear().toString(), now.getMonth().toString().padStart(2, '0'), now.getDate().toString().padStart(2, '0')].join('-'); + let timeString = [now.getHours().toString().padStart(2, '0'), now.getMinutes().toString().padStart(2, '0')].join(':'); + setActionStatus('Bookmarking tabs…', 'processing', function() { + getOrCreateFolder(function(rootId) { + chrome.bookmarks.create({'title': dateString + ' ' + timeString, parentId: rootId}, function(folder) { + chrome.tabs.query({}, function(tabs) { + let remaining = tabs.length; + for (let tab of tabs) { + chrome.bookmarks.create({'title': tab.title, url: tab.url, parentId: folder.id}, function() { + if (chrome.runtime.lastError) { + setActionStatus('Error bookmarking tabs', 'error', function() {}); + } + + remaining--; + if (remaining === 0) { + bookmarkingTabs = false; + setActionStatus('Bookmark open tabs', 'icon', function() {}); + } + }); + } + }); + }); + }); + }); +} + +chrome.browserAction.onClicked.addListener(bookmarkTabs); + +chrome.runtime.onInstalled.addListener(function () { getOrCreateFolder(function () {}); }); diff --git a/icons/error-32.png b/icons/error-32.png new file mode 100644 index 0000000000000000000000000000000000000000..8050564ad8ce9977b1d7d258a65d57f50da2daf8 GIT binary patch literal 426 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7lxM%Zx|SA>di%gBAf*t zk;M!Q+`=Ht$S`Y;1W=H@#M9T6{V9_;lZiaXSF_zfA=%83h!W@g+}zZ>5+Ij>!MP|k zu_QG`p**uBL&4qCHy}kXm7Rfsk^AgqOOO!jKEn5o zU16%3;kM*SQBE9B3!iT;7G!8<7A>|&;QyY)#t<=WsfC4au(9NqChis=6%D363tBuG z|4oi7W@To0URqskw!p36M0PZriO`=-oTd-fKmT@b|IThE!I{;Z8(7{2K1^I&{UF9f zJ7MCynf~VmKill~IuP~Yl8uW_Q@mh8`xpBKLOZT7x4Z5>R~@(gac4(pLNC+ypW9cm zuiLb~H#>Ckg5>btDU;$EeZ|^EtFH%Vf14%bsTIJ#f4Y~W?y}_2l`c&0cRd&V+Z4)V z``=UP>@%0Rq62$HGWPa`nm<_nKU>Oh$^r9&rJpyp-!Fb|&B|t09KDBeg>dOyofG$c PKtbl|>gTe~DWM4fa($c* literal 0 HcmV?d00001 diff --git a/icons/error-48.png b/icons/error-48.png new file mode 100644 index 0000000000000000000000000000000000000000..7e33ee41724849a80a1dbaa72207baeb0e00d0d0 GIT binary patch literal 524 zcmV+n0`vWeP)WFU8GbZ8()Nlj2>E@cM*00D4GL_t(&-tAYx4Z|P| z#3&S7F&5i$&mMamBDqeVq&2sPNoscI=t%$@IWZ0G(lHlX1QD%>HK90wMzI}tkP zT#T{lq7Z@z39nW87-KVe4g#*H`h^^*MF4xjhY*e|#P$Zz*$iN}P;0E4TyFnjD)F6> zAfMM(05z&FML-QasSCCG{(d{O5n5FMwJI+`Kpi|M0i;?>^H0p)?>SZSgRRr8!lY## z<{ZFkp_c0BXAtr5%VSv-HQs zsKBWTfR+Lj@Kg(d)RftiPy7v7+6P42X39Iyvn>UzOry=!&legA70f9>CE=yLf5oL< zRRu3ueGL-cBKUork$~FtIhsJBi+#7ySg3vtLsbEz0qRrcdwax>1?JlcGEkR)P(A8>cun}dXG)T^j8M|6Y&6!a-~rKn_(OP O0000WFU8GbZ8()Nlj2>E@cM*00PfRL_t(|+U;E1ZNo4O zln9Rypo?XgjF4fnSb^@qeiUg9Luq826d$?+{E;6=zT=%}*>WiW006+OsLJQ(;NuT1 z04Fal*MsEAobGC1P4XX)hu9xnuh%pps0$!Tynrw@y8ve7cM9T807{(utpebz0=T=d zD4>DW2NyK3WXb(?-g^;$gaceu({{4m{`TwwQntH?*3ueqaHoD6AqU95n_n4k{`uY?kC|)9Zv)SSepFCIT!-i#{)xvfj3*8W6b3o zph1{d5y)Hh4ztiXiRkf6)<*I9v*Vw=oO_Fk52wHW@D-24PJK^L{hd+Fn?_ z-|wZAQf{}KTL-W;`P=_|MdnfRJv$(L?zhN4LcE0oTs>Mm;sR;%r5&*AiBqIiPRYoz zasYcIzsCid{5kG6#gN zehU}C0ZF@{@GsSlazW@XW_?`#juFrh0TE>EVwF#pWqPMyJBlbeITj!3kQ9MX{kBnr zIlwrI2-R;JMI=Q&x}vcHr2c-x$S5MOl`%^c(b?*sk^I&*9~FVlkdLnDya;rL{Mn;N zLWFu$fZ54kqhm3!o^=4CN2v*^5MT&SI{;7u1n_E&;P{P9W`4W<>&pI=Nt{7bQnpU}4^T)pGbEzKIX^cyHLnE7WngeFN=+^NAIP=-j-9KvPte)(sS)s6SjY^ML zMK6oYk?iIWN3FMV%wnyQTlouSiOU>y^86gw{Z43(l@UiS+Ya7IkNR})ZO;~E=9zh& z?U$9-1J-`SfD{)7`2!La9gGoEZWVv4nb0ax(8coMh4d8Wh6y4Jfe&K%6^?RO%U#fM zZrinDZS85h4c(7kt)I(~{Jn~k+3oQYGv=Lk0l7!lN=~q6J{*61qtTu_@yER$Fqf=e idG)(h^?%`jI@K`#?Qv^XiV80Tg^H)EpUXO@geCyQU6K+2 literal 0 HcmV?d00001 diff --git a/icons/icon-48.png b/icons/icon-48.png new file mode 100644 index 0000000000000000000000000000000000000000..a89bbcfed76264d42a6694128d8e4c5d5ba7feb0 GIT binary patch literal 497 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCwj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&pI=Nt{8Gqx>8SLSPvp*y=ge7dS z>kD7H%Eb4Pgm<|-D|wlwT&g`Txj~6R_rp#no<&(3Uq-E%y49yk`SLu6tc0Dcu?)$5~P~g!8of!G|yEuM0R5KK3GQHV#)T*KQP2;mXucKGO jr?>|i?^bTMcdcbyX;`bjIzjj*DC9j|{an^LB{Ts5?c}@v literal 0 HcmV?d00001 diff --git a/icons/icon-96.png b/icons/icon-96.png new file mode 100644 index 0000000000000000000000000000000000000000..93861f670f21906c43294185233387eda8fc0f52 GIT binary patch literal 780 zcmV+n1M~ceP)WFU8GbZ8()Nlj2>E@cM*00MAHL_t(|+U=XoQNu70 zg|!-|Fj}AhZnVLHHgcl?TA(lv;sP@nMvfi*?P~SCD~#j3Py2S|$RQwv5L#8z`TA+{ z`=1&>a=y4s-(*^>(oNl1*8G>(?`9wHalN>K&>cWa;~Rhx?*P=yKMBMffao~)a|GZQgQ!wF;ObdMsB#?EFR1i7}K0syMnw{B$}6A%sxJhB9j6DSYzj z8^Gvs(=!CIZoYR2(@a5LH+c~gCW@f{06wmlbn~|%KX!PFA~s^Pj-kK0eU2oIrpf?V z&qNRa5C8yx00004fGM;s{M|<$Mv&D2OmotM2qJ=%OC^;Ri%33IzTTcg2q8SZe*&P! z;2QI1t$-;W?B&caG2VI)NGq7%x&l%#{z!T+I*#J1W#r5>1trVSTA1GhfUA?%z0GeC zLAm4YrBT%KT2&L#y{Kwweybj^XI#ld(;b2p<6Af3doOyVo&PTZDx;0>X@2V|=#jT= zj-c#atGF6&P5z4_P2+oQ#H6AjKMGG~i<{9qVd*>}HSY~0jn{Y-A)2G>(FCMn{%8P? zf*A%#%X}*UO3Zh23UBjn{?ViZfCX2*RRF1?PXIu%Nf%8&R-$P$y!w|o?jA9JZ2(J~ zuMJ>%^Q|@EZsuFw3qWFU8GbZ8()Nlj2>E@cM*00CP`L_t(o!_`+gZo@DT z+%=q+q|19$GZpiJGzaU*|y(e8>!T^&ZUV#?KGz2HfR<*gxuCWRMHfWTi;`xT`KAhA-|u}D zh%IP2rduj-wt$*?-v>$=p!t6ofmo<<0$RY$1WIT7wM92`v>>V?P;(YY3vzjI tO~B(cum?^7?yY>(eI56HCjkAI@e2p>xAK_P$OHfY002ovPDHLkV1l@5%*Ox# literal 0 HcmV?d00001 diff --git a/icons/processing-48.png b/icons/processing-48.png new file mode 100644 index 0000000000000000000000000000000000000000..b9fff57e3a249320502d9525f0c51a675b9faa44 GIT binary patch literal 653 zcmV;80&@L{P)WFU8GbZ8()Nlj2>E@cM*00HqyL_t(&-tCt=Zo@DP zhDpOYNw=QIvpcyL=#nF3=?SuB_Ia}9BrfoGsRGrNEsB&ZHwb|YdC}ib@g<_C)iqZ9 z2OB)2m~&JNoY@hGh{kbLJ*extA|jftB0r9!T6_)xWQqQQ4{Rj>x!_9`F^G1{mN$i- zw)HXf!=!S0IUni^(8Bv7`eB0LcU)A!<$ORtOs0t)g7n2%M6eKs6HX)v%n8wo5DSok zXkaWNvb51$=}>%?CQ7A zUIQ!ekS>Kj@Er12h?%4CDK!9p4&;cu59oyX-?`_#zI^8GLJ@c*o@j7oNm*kg0(hmE zLd`&&Nvc$Rb@tF;BdQ)_D%0>t3+e!rQ3`KIX21LTVO_4XldpXPP?N017hnX}bG zlM;Owb#H$+U;e9IXe|3sXpz&TkGKYwVAU7#jIFe-aqRve>xYT1H&R8vng9px*N+BX z)%sHJ!IF!*6yCbbC4;Thl<2xxB!!H(F#w>;nI5Nz6VhfM0%Fh+V6H8Im$ujia87l& nc{W*@TH24Pg4z6M_=m7>KZyd!T;=}I00000NkvXXu0mjf_DdX3 literal 0 HcmV?d00001 diff --git a/icons/processing-96.png b/icons/processing-96.png new file mode 100644 index 0000000000000000000000000000000000000000..3c58dd4f1ed7613dae724ac802fe709d4c8e4559 GIT binary patch literal 1092 zcmV-K1iSl*P)WFU8GbZ8()Nlj2>E@cM*00XE=L_t(|+U;FCj@vL0 z^$7Aw(&ap^wUzb)X?z4VIe|OZKF@Z05-l((0tH$|q<-@wIRhA2_#;#Az4@BbUM_BK zZfqYhjx7)2464(i#1fGBxD4hT`@HY}- zj)11%xW6O-ER_IrCzgvfg6eZGSg^LVxL=zGWD$BSdqKl|qHY_?P*0$WrF-Le7Fq?l zxw*M9CX}upMHcvcT%7d55HR? z7qnKuuSxZ)IlvJ3m{?=DJ~o_NP1Q4kj{@gILQqp6_!POIoFr@=d_-J)ti2~@!!TTi zVX%>eEyVj2SV!&c{VNK-nJVZ2_$-4x@~Q>kza)JGc-9a^pnS{){GUI5o9P4a^7l6Z zvo$^d912%!pEI3=Pk?XE3#ipko&z+7SyFX8*M@|%9sq<31a2>gm62UPetRwqIZNk8 zp?<0m1c_z_t&xx_EdgLtyr%-6G6bbA^uRr{k;t)7qCDN=#gyQ4oDdSO1y8IQ!^&o^ z?CH5!Lq!4p{eIuHX6i-^PLP2+-*-wpb3)dXPpx{XQ3McrN3`!CDwR)nv=#~28ahOh z?AlC71AJ)$j^-hDg0#T5LckI5i~0GoEggK$IZmkr6t8-#1fXEQ;si)Fiy9;590|ah zRL@Sp&arg0;Ik00^o!W^+yW71!Tbfr~^>bE0 zxpcxLNx0}f;LI%pYF2+W9$+cyR!P88(w)LmtO}D*ziJ;~!L-4zG6_$hb8a_u0%l;p zy?>c(_QVO`xFHf%1E-;U6%Ww9KU+`+|NFbxZ7I*k6)b>m;J%~LU3{&;$%~K>gtu>- zbDs~pd8!psU{&MhU}vo zkX&f7#gPT9JOn9=)Co|I3{HS@NcMl^rkoF*0OexD32<|BQ?x%xK-L%%=L35H0000< KMNUMnLSTY!^UR9? literal 0 HcmV?d00001 diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..3e49448 --- /dev/null +++ b/manifest.json @@ -0,0 +1,31 @@ +{ + "manifest_version": 2, + "name": "Autobookmarker", + "version": "1.0", + + "description": "Automatically bookmarks open tabs", + "icons": { + "32": "icons/icon-32.png", + "48": "icons/icon-48.png", + "96": "icons/icon-96.png" + }, + + "permissions": [ + "tabs", + "bookmarks", + "storage" + ], + + "browser_action": { + "default_icon": { + "32": "icons/icon-32.png", + "48": "icons/icon-48.png", + "96": "icons/icon-96.png" + }, + "default_title": "Bookmark open tabs" + }, + + "background": { + "scripts": ["background.js"] + } +}