From 888e8d931072f66f6100a1c40974768d63073286 Mon Sep 17 00:00:00 2001 From: Seth Soffer Date: Wed, 12 Apr 2023 10:17:07 -0400 Subject: [PATCH 1/3] Trim Querystring from url --- Scripts/TrimQueryStringFromUrl.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Scripts/TrimQueryStringFromUrl.js diff --git a/Scripts/TrimQueryStringFromUrl.js b/Scripts/TrimQueryStringFromUrl.js new file mode 100644 index 00000000..b5ee1d13 --- /dev/null +++ b/Scripts/TrimQueryStringFromUrl.js @@ -0,0 +1,18 @@ +/** + { + "api":1, + "name":"Trim Query String from URL", + "description":"Cleans up a URL by removing the query string.", + "author":"Seth Soffer", + "icon":"link", + "tags":"url,trim,querystring,query string", + } + **/ +function main(state){ + const url = state.text; + const queryIndex = url.indexOf('?'); + if(queryIndex > -1){ + state.text = url.slice(0, queryIndex); + } +} +1 From 48d3075a0c2297418f41f61b0a43202fc6eb1f31 Mon Sep 17 00:00:00 2001 From: Seth Soffer Date: Wed, 12 Apr 2023 18:19:35 -0400 Subject: [PATCH 2/3] Date to Millis boop script --- Scripts/DateToMillis.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Scripts/DateToMillis.js diff --git a/Scripts/DateToMillis.js b/Scripts/DateToMillis.js new file mode 100644 index 00000000..0670ee86 --- /dev/null +++ b/Scripts/DateToMillis.js @@ -0,0 +1,23 @@ +/** + { + "api":1, + "name":"Date to Milliseconds", + "description":"Converts a date to milliseconds since the UNIX epoch.", + "author":"Seth Soffer", + "icon":"watch", + "tags":"date,unix,milliseconds,timestamp", + } + **/ +function main(state){ + try{ + const parsedDate = Date.parse(state.text); + if (isNaN(parsedDate)){ + state.postError("Invalid date."); + return; + } + state.text = parsedDate; + } + catch (error){ + state.postError("Error parsing date."); + } +} From e2302582a443400c895d8154dc948ca319c8d2cc Mon Sep 17 00:00:00 2001 From: Seth Soffer Date: Wed, 12 Apr 2023 18:26:19 -0400 Subject: [PATCH 3/3] stray character removal --- Scripts/TrimQueryStringFromUrl.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Scripts/TrimQueryStringFromUrl.js b/Scripts/TrimQueryStringFromUrl.js index b5ee1d13..3dd9e5b3 100644 --- a/Scripts/TrimQueryStringFromUrl.js +++ b/Scripts/TrimQueryStringFromUrl.js @@ -15,4 +15,3 @@ function main(state){ state.text = url.slice(0, queryIndex); } } -1