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."); + } +} diff --git a/Scripts/TrimQueryStringFromUrl.js b/Scripts/TrimQueryStringFromUrl.js new file mode 100644 index 00000000..3dd9e5b3 --- /dev/null +++ b/Scripts/TrimQueryStringFromUrl.js @@ -0,0 +1,17 @@ +/** + { + "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); + } +}