diff --git a/src/sw.ts b/src/sw.ts
index f8c07c0d4fe44e82e58b496dd6dad429b05aa7b5..26848164542da8dbc4aa7ea59ee8dda4ae262361 100644
--- a/src/sw.ts
+++ b/src/sw.ts
@@ -3,7 +3,6 @@ import { precacheAndRoute } from 'workbox-precaching'
 import { Server } from 'revolt.js/dist/api/objects'
 import { Channel, Message, User } from 'revolt.js'
 import { IDBPDatabase, openDB } from 'idb'
-import { decodeTime } from 'ulid'
 
 declare let self: ServiceWorkerGlobalScope
 
@@ -14,6 +13,27 @@ self.addEventListener('message', (event) => {
 
 precacheAndRoute(self.__WB_MANIFEST)
 
+// ulid decodeTime(id: string)
+// since crypto is not available in sw.js
+const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
+const ENCODING_LEN = ENCODING.length
+const TIME_LEN = 10
+
+function decodeTime(id: string) {
+    var time = id.substr(0, TIME_LEN)
+		.split("")
+		.reverse()
+		.reduce(function (carry, char, index) {
+			var encodingIndex = ENCODING.indexOf(char);
+			if (encodingIndex === -1)
+				throw "invalid character found: " + char;
+			
+			return carry += encodingIndex * Math.pow(ENCODING_LEN, index);
+		}, 0);
+	
+    return time;
+}
+
 const base_url = `https://autumn.revolt.chat`;
 self.addEventListener("push", event => {
 	async function process() {