Explorar o código

fix(#85): use ?time_continue param instead of ?t

Sv443 hai 11 meses
pai
achega
e77ba3b6f9
Modificáronse 5 ficheiros con 8 adicións e 9 borrados
  1. 1 1
      changelog.md
  2. 1 1
      src/config.ts
  3. 4 4
      src/features/input.ts
  4. 1 1
      src/features/layout.ts
  5. 1 2
      src/index.ts

+ 1 - 1
changelog.md

@@ -18,7 +18,7 @@
 - **Plugin Changes:**
   - Added new components:
     -  `createLongBtn()` to create a button with an icon and text (works either as normal or as a toggle button)  
-      The design matches that of the subscribe button on YTM's channel pages, but the consistent class names make it easy to style it differently.
+      The design follows that of the subscribe button on YTM's channel pages, but the consistent class names make it easy to style it differently.
     - `showToast()` to show a custom toast notification with a message string or element and duration
     - `showIconToast()` to show a custom toast notification with a message string or element, icon and duration
     - `createRipple()` to create a click ripple animation effect on a given element (experimental)

+ 1 - 1
src/config.ts

@@ -203,7 +203,7 @@ export async function promptResetConfig() {
       const url = new URL(location.href);
       url.searchParams.delete("t");
       if(videoTime)
-        url.searchParams.set("t", String(videoTime));
+        url.searchParams.set("time_continue", String(videoTime));
       location.replace(url.href);
     }
     else

+ 4 - 4
src/features/input.ts

@@ -97,7 +97,7 @@ async function switchSite(newDomain: Domain) {
     log(`Found video time of ${vt} seconds`);
 
     const cleanSearch = search.split("&")
-      .filter((param) => !param.match(/^\??t=/))
+      .filter((param) => !param.match(/^\??(t|time_continue)=/))
       .join("&");
 
     const newSearch = typeof vt === "number" && vt > videoTimeThreshold ?
@@ -105,8 +105,8 @@ async function switchSite(newDomain: Domain) {
         ? `${cleanSearch.startsWith("?")
           ? cleanSearch
           : "?" + cleanSearch
-        }&t=${vt}`
-        : `?t=${vt}`
+        }&time_continue=${vt}`
+        : `?time_continue=${vt}`
       : cleanSearch;
     const newUrl = `https://${subdomain}.youtube.com${pathname}${newSearch}${hash}`;
 
@@ -223,7 +223,7 @@ export async function initAutoLike() {
 
       siteEvents.on("pathChanged", (path) => {
         if(getFeature("autoLikeChannelToggleBtn") && path.match(/\/channel\/.+/)) {
-          const chanId = path.split("/").pop();
+          const chanId = path.split("/").pop(); // TODO:FIXME: this doesn't work for paths like /channel/@User/videos
           if(!chanId)
             return error("Couldn't extract channel ID from URL");
 

+ 1 - 1
src/features/layout.ts

@@ -416,7 +416,7 @@ export async function initAboveQueueBtns() {
             return;
           const url = new URL(location.href);
           url.searchParams.delete("list");
-          url.searchParams.set("t", String(await getVideoTime(0)));
+          url.searchParams.set("time_continue", String(await getVideoTime(0)));
           location.assign(url);
         }
         catch(err) {

+ 1 - 2
src/index.ts

@@ -60,12 +60,11 @@ import {
 /** Stuff that needs to be called ASAP, before anything async happens */
 function preInit() {
   try {
-    const domain = getDomain();
     log("Session ID:", getSessionId());
     initInterface();
     setLogLevel(defaultLogLevel);
 
-    if(domain === "ytm")
+    if(getDomain() === "ytm")
       initBeforeUnloadHook();
 
     init();