diff --git a/Ecosia/Ecosia.js b/Ecosia/Ecosia.js index dd7a2dc..3d61858 100644 --- a/Ecosia/Ecosia.js +++ b/Ecosia/Ecosia.js @@ -6,7 +6,10 @@ let widgetInputRAW = args.widgetParameter; let token; if (widgetInputRAW !== null) { - token = widgetInputRAW.toString(); + token = widgetInputRAW.toString().trim(); + if (/^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/.text(token) === false) { + throw new Errpr('Invalid Token Format') + } } else { throw new Error('No token set via widget parameter! You can request a token here: https://www.ecosia.org/account/login') } diff --git a/Ecosia/README.md b/Ecosia/README.md index cd92da5..d58c858 100644 --- a/Ecosia/README.md +++ b/Ecosia/README.md @@ -2,15 +2,15 @@ ![Ecosia Widget Preview light](https://raw.githubusercontent.com/ThisIsBenny/iOS-Widgets/main/Ecosia/previewLight.jpeg) ![Ecosia Widget Preview dark](https://raw.githubusercontent.com/ThisIsBenny/iOS-Widgets/main/Ecosia/previewDark.jpeg) -This widget allows you to save the location of your car, which will then displayed in the widget as a map. So you know exactly where you parked. -If you don't know the way to the car anymore, you can start the navigation to the car's location with one click and let Apple Maps or Google Maps navigate you. +This widget shows how many trees you have already planted based on your searches on Ecosia.org. +Clicking on the widget will open Ecosia.org in your browser. [[Download]](https://raw.githubusercontent.com/ThisIsBenny/iOS-Widgets/main/Ecosia/Ecosia.js) ## Setup For this widget is a ecosia account required. Go to https://www.ecosia.org/account/login and enter your E-Mail address. You will recieve a E-Mail with a link. Use this Link on all your devices where you use Ecosia to connect all Devices to one counter (you can request the Mail multiple time, import is that the E-Mail address is always the same). -After this, you have to copy the token from the Link in the E-Mail and paste the token to the widget parameter +After this, you have to copy the token from the Link in the E-Mail and paste the token to the widget parameter. The Token is the part behind `https://www.ecosia.org/account/verify?token=[TOKEN]` in the url: ![Get Token](https://raw.githubusercontent.com/ThisIsBenny/iOS-Widgets/main/Ecosia/token.jpeg) ![Setup](https://raw.githubusercontent.com/ThisIsBenny/iOS-Widgets/main/Ecosia/setup.jpeg) \ No newline at end of file diff --git a/Widget-Catalog/catalog.json b/Widget-Catalog/catalog.json index b9326dc..01cf07e 100644 --- a/Widget-Catalog/catalog.json +++ b/Widget-Catalog/catalog.json @@ -14,6 +14,13 @@ "previewURL": "https://raw.githubusercontent.com/ThisIsBenny/iOS-Widgets/main/Covid-19/previewLight.jpeg", "descriptionURL": "https://github.com/ThisIsBenny/iOS-Widgets/blob/main/Covid-19/README.md" }, + { + "name": "Ecosia Tree Counter", + "version": "1.0.0", + "scriptURL": "https://raw.githubusercontent.com/ThisIsBenny/iOS-Widgets/main/Ecosia/Ecosia.js", + "previewURL": "https://raw.githubusercontent.com/ThisIsBenny/iOS-Widgets/main/Ecosia/previewLight.jpeg", + "descriptionURL": "https://github.com/ThisIsBenny/iOS-Widgets/blob/main/Ecosia/README.md" + }, { "name": "Meeting dial in", "version": "0.1.1",