Browse Source

fix: remove anchor from homepageURL

Sven 1 year ago
parent
commit
c0c09930a3
3 changed files with 18 additions and 17 deletions
  1. 17 0
      src/dev/parseVideoTime.ts
  2. 1 1
      src/tools/post-build.ts
  3. 0 16
      src/utils.ts

+ 17 - 0
src/dev/parseVideoTime.ts

@@ -0,0 +1,17 @@
+/** Parses a video time string in the format `[hh:m]m:ss` to the equivalent number of seconds - returns 0 if input couldn't be parsed */
+function parseVideoTime(videoTime: string) {
+  const matches = /^((\d{1,2}):)?(\d{1,2}):(\d{2})$/.exec(videoTime);
+  if(!matches)
+    return 0;
+
+  const [, , hrs, min, sec] = matches as unknown as [string, string | undefined, string | undefined, string, string];
+
+  let finalTime = 0;
+  if(hrs)
+    finalTime += Number(hrs) * 60 * 60;
+  finalTime += Number(min) * 60 + Number(sec);
+
+  return isNaN(finalTime) ? 0 : finalTime;
+}
+
+void [parseVideoTime];

+ 1 - 1
src/tools/post-build.ts

@@ -47,7 +47,7 @@ const devDirectives = mode === "development" ? `
   const header = `\
 // ==UserScript==
 // @name           ${pkg.userscriptName}
-// @homepageURL    ${pkg.homepage}#readme
+// @homepageURL    ${pkg.homepage}
 // @namespace      ${pkg.homepage}
 // @version        ${pkg.version}
 // @description    ${pkg.description}

+ 0 - 16
src/utils.ts

@@ -153,22 +153,6 @@ function ytForceShowVideoTime() {
   return true;
 }
 
-// /** Parses a video time string in the format `[hh:m]m:ss` to the equivalent number of seconds - returns 0 if input couldn't be parsed */
-// function parseVideoTime(videoTime: string) {
-//   const matches = /^((\d{1,2}):)?(\d{1,2}):(\d{2})$/.exec(videoTime);
-//   if(!matches)
-//     return 0;
-
-//   const [, , hrs, min, sec] = matches as unknown as [string, string | undefined, string | undefined, string, string];
-
-//   let finalTime = 0;
-//   if(hrs)
-//     finalTime += Number(hrs) * 60 * 60;
-//   finalTime += Number(min) * 60 + Number(sec);
-
-//   return isNaN(finalTime) ? 0 : finalTime;
-// }
-
 /**
  * Returns the current domain as a constant string representation
  * @throws Throws if script runs on an unexpected website