From 318581ab84984a18b233b60f765933b62eb9bae3 Mon Sep 17 00:00:00 2001 From: Tshaka Lekholoane Date: Sat, 25 Nov 2023 17:54:37 +0200 Subject: [PATCH] feat: create extension --- .gitignore | 1 + LICENCE | 15 +++++++++++++++ README.md | 13 +++++++++++++ background.js | 29 +++++++++++++++++++++++++++++ icons/128.png | Bin 0 -> 3555 bytes icons/16.png | Bin 0 -> 913 bytes icons/32.png | Bin 0 -> 1232 bytes icons/48.png | Bin 0 -> 1562 bytes invert.css | 3 +++ manifest.json | 35 +++++++++++++++++++++++++++++++++++ 10 files changed, 96 insertions(+) create mode 100644 .gitignore create mode 100644 LICENCE create mode 100644 README.md create mode 100644 background.js create mode 100644 icons/128.png create mode 100644 icons/16.png create mode 100644 icons/32.png create mode 100644 icons/48.png create mode 100644 invert.css create mode 100644 manifest.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..f5c579f --- /dev/null +++ b/LICENCE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2023 Tshaka Lekholoane + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9380b82 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# Invert + +A Chrome extension to invert the colours of a web page. + +## Usage + +Click the extension button or use the shortcut ⌃ + B or ⌘ + B on macOS to toggle the colours on the page in the current tab. + +## Installation + +1. Go to the extensions page by entering `chrome://extensions` in a new tab. +2. Enable Developer Mode by clicking the toggle switch in the upper right corner. +3. Click the **Load unpacked** button and select the extension directory. \ No newline at end of file diff --git a/background.js b/background.js new file mode 100644 index 0000000..ea2a3f1 --- /dev/null +++ b/background.js @@ -0,0 +1,29 @@ +chrome.runtime.onInstalled.addListener(() => { + chrome.action.setBadgeText({ text: "OFF" }); +}); + +const toggle = (state) => state === "ON" ? "OFF" : "ON"; + +chrome.action.onClicked.addListener(async (tab) => { + let state = await chrome.action.getBadgeText({ tabId: tab.id }); + state = toggle(state); + + await chrome.action.setBadgeText({ + tabId: tab.id, + text: state, + }); + + const details = { + files: ["invert.css"], + target: { tabId: tab.id }, + }; + + switch (state) { + case "ON": + await chrome.scripting.insertCSS(details); + break; + case "OFF": + await chrome.scripting.removeCSS(details); + break; + } +}); diff --git a/icons/128.png b/icons/128.png new file mode 100644 index 0000000000000000000000000000000000000000..bd6fde2a1c3e9a5012a5c99bd316e5b1fa0de666 GIT binary patch literal 3555 zcmbtXc|6qH`#)nCjGbJDduwp*nHdzC29qr*g-R3}+n}t2jD2V%E%=H`*H$hiON6Y$ z*j-DaTbAs5mI!0d{6@E5_xJnv_dB20`8>~g&ii>k=Q-zjea`C>V|Ml=A6xN>HW4#-6?Auv_-Q|So2>^=Xcy{eMSYxE4v4trBL2@h{6@cx1{44jAm*J?X^vw}P@Sz#5lu~j5=-X-91vjuWoZ!B10WJ$pN*vf6Nuzb-2$TU1H%SD zv>Ramfw|0*`^}iu_kI46&)O&*re;WeFOoA-1BF3hq;=p(Boaq*B4RBJjDEPYM%vP@etzCqG&&$402QE) z@*=sQRgWDzhQ_F&)znm22o>KzPd|IIil?v4KP3OnW8m!TNOJS`bM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000000000000000000000000000000000000000..51b5ef59c881ecc30a3192ae27fb318ec11d961e GIT binary patch literal 913 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6-E$sR$z z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$XBDAAG{;hE;^%b*2hb1<+n z3NbJPS&Tr)z$nE4G7ZRL@M4sPvx68lplX;H7}_%#SfFa6fHVkr05M1pgl1mAh%j*h z6I`{x0%imor0saV%ts)_S>O>_%)r1c48n{Iv*t(uO^eJ7i71Ki^|4CM&(%vz$xlkv ztH>0+>{umUo3Q%e#RDspr3imfVamB1>jfNYSkzLEl1NlCV?QiN}Sf^&XRs)CuG zfu4bq9hZWFf=y9MnpKdC8&o@xXRDM^Qc_^0uU}qXu2*iXmtT~wZ)j<0sc&GUZ)Btk zRH0j3nOBlnp_^B%3^4>|j!SBBa#3bMNoIbY0?6FNr2NtnTO}osMQ{LdXGvxn!lt}p zsJDO~)CbAv8|oS8!_5Y2wE>A*`4?rT0&NDFZ)a!&R*518wZ}#uWI2*!AU*|)0=;U- zWup%dHajlKxQFb(Ko;_JaSX8#TsmpL7qg>4`};q|oJu!5xtIkfIUUsEU*MncQd{MG z+Elxj!OJFvIC>-}FD~G46W)J6m3`XRXI!#BZrq&t^X$2Mant^uElPQGf13QYEgRnX zs>dwSUSQ)P<*}vv!>l{O#q5zbjk7#$S`7Cb6NUq?qbGb?hSg%_wVSP>ohZKy!*FphTpZ0_Y-EVtKc!7uxta{ zuKVH{YcyZ{JEb}8R$IfmpvYfb%!^)6xP1JR&n~ZQ;TxXIRl*#X7TRv+-}hcc+u6{1-oD!M<+PfD4 literal 0 HcmV?d00001 diff --git a/icons/32.png b/icons/32.png new file mode 100644 index 0000000000000000000000000000000000000000..a6d7f589e034ec659dc3a433619ea1f50f0fdd87 GIT binary patch literal 1232 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmUKs7M+SzC{oH>NSwWJ?9znhg z3{`3j3=J&|48MRv4KElNN(~qoUL`OvSj}Ky5HFasE6@fg(UKbBnda-upao=eFt9QT zF)#yJj6lf1D8&FW4aj2fVw8rngBUfSYM2-p+A|qgplYIkGzfSAF-Q-DW?sOEFmVAB zT(!aiW&|6gEq)LG2Oz~+;1OBOz`!jG!i)^F=12fdi_8p(D2ed(u}aR*)k{ptPfFFR z$SnZrVz8;O0y1+`OA-|-a&z*EttxDlz$&bOY>=?Nk^)#sNw%$0gl~X?bAC~(f|;Iy zo`I4bmx6+VO;JjkRgjAtR6CGotCUevQedU8UtV6WS8lAAUzDzIXlZGwZ(yWvWTXpJ zp<7&;SCUwvn^&w1F$89gOKNd)QD#9&W`3Rm$lS!F{L&IzB_)tWZ~$>KW+6%?4_<0f}1q7iFdbZ3dZdXJ`Xfi6REI$3`DyIg(=_J_U;cy=up0 zqYn=@J1)t%hwKatOo5&*jv*18Z>RdM_6?M1c>h(G*-Pl8yAqf4!aOg{G^2!Nf0$E~ z7Ww>T{C}XQu~YG+kC5jT-}D6rJ4&4==AYkuuFCrNyKiyFFWzh~x?gqe`|pkSzRs&% zwoL4){pkZi@3iYXE=jLxjxLbbJ7^kk=eHTl+-&tFQa(}IsRzujA7l;q$XU}Mz2HsDH z{{7PHz3cm9x!-C0 zkgVgeHTXMMM4{}m@R7IMjlLhNn|J<@Yk-yJzI`tpr5!6if8L;PK*B8 n?h;pLy?Ar?@Xe(E{wWW{E5))b>$dC*2jx>wS3j3^P6v% literal 0 HcmV?d00001 diff --git a/icons/48.png b/icons/48.png new file mode 100644 index 0000000000000000000000000000000000000000..024e6adabe000b179eeb5f33e12da6d1ded45984 GIT binary patch literal 1562 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCmUKs7M+SzC{oH>NS%G|oWRD45dJguM!v-tY$DUh!@P+6=(yLXi1ImO!M_+&;qhK7+4vF z7?^=9Mj&Khlwtsx24pdKF-pVPL5vzuHB1Z)?U@WLP&H9N8U#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)GrEpzl^}{(!f_MX_|M<3WsvV~?lR5vR zy*by~)B~>x-JX)VBceiWLg}@WA<;*lyi(j~*Rz9BVAFj4{M5x$`>U7?JnuXFDRKKG zU$O1hqx7{5e-1iy$ItDk|GZ^yt&vr*y{tmL&yGqv?mIRfidqu_SN{8=8$6A3ZHc;% zY{Xad=q*){kStflhL9-I{Cu^Zr6)jwH`=kR116)ef4$G5yM7yN5=2=kIN5v zAAEG})1F+bc*c%GTc-clG_v>j?9ft}{MYVe*{we%$I83d%m1EyQ0y^l+D(Da?=G|k zWqNL1UP98XO_CUTv W_5`H_ZVLfWiRbC+=d#Wzp$P!Sd{M;! literal 0 HcmV?d00001 diff --git a/invert.css b/invert.css new file mode 100644 index 0000000..5c6ca1e --- /dev/null +++ b/invert.css @@ -0,0 +1,3 @@ +html { + filter: invert(90%); +} diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..05b7e62 --- /dev/null +++ b/manifest.json @@ -0,0 +1,35 @@ +{ + "manifest_version": 3, + "name": "Invert", + "description": "Invert the colour of web pages.", + "version": "1.0", + "icons": { + "16": "icons/16.png", + "32": "icons/32.png", + "48": "icons/48.png", + "128": "icons/128.png" + }, + "background": { + "service_worker": "background.js" + }, + "action": { + "default_icon": { + "16": "icons/16.png", + "32": "icons/32.png", + "48": "icons/48.png", + "128": "icons/128.png" + } + }, + "permissions": [ + "scripting", + "activeTab" + ], + "commands": { + "_execute_action": { + "suggested_key": { + "default": "Ctrl + B", + "mac": "Command + B" + } + } + } +} \ No newline at end of file