Ver código fonte

ref: minor stuff

Sv443 1 ano atrás
pai
commit
c4b135b4a6
3 arquivos alterados com 12 adições e 72 exclusões
  1. 6 4
      dist/BetterYTM.user.js
  2. 0 64
      src/dev/numKeysJumpTo.js
  3. 6 4
      src/utils.ts

+ 6 - 4
dist/BetterYTM.user.js

@@ -245,7 +245,7 @@ const scriptInfo = {
     name: GM.info.script.name,
     version: GM.info.script.version,
     namespace: GM.info.script.namespace,
-    lastCommit: "3106b2b", // assert as generic string instead of literal
+    lastCommit: "9aca99d", // assert as generic string instead of literal
 };
 
 
@@ -2515,8 +2515,13 @@ __webpack_require__.r(__webpack_exports__);
 
 //#SECTION logging
 let curLogLevel = 1;
+/** Common prefix to be able to tell logged messages apart and filter them in devtools */
+const consPrefix = `[${_constants__WEBPACK_IMPORTED_MODULE_1__.scriptInfo.name}]`;
+const consPrefixDbg = `[${_constants__WEBPACK_IMPORTED_MODULE_1__.scriptInfo.name}/#DEBUG]`;
 /** Sets the current log level. 0 = Debug, 1 = Info */
 function setLogLevel(level) {
+    if (curLogLevel !== level)
+        console.log(consPrefix, "Setting log level to", level === 0 ? "Debug" : "Info");
     curLogLevel = level;
 }
 /** Extracts the log level from the last item from spread arguments - returns 0 if the last item is not a number or too low or high */
@@ -2526,9 +2531,6 @@ function getLogLevel(args) {
         return (0,_sv443_network_userutils__WEBPACK_IMPORTED_MODULE_0__.clamp)(args.splice(args.length - 1)[0], minLogLvl, maxLogLvl);
     return 0;
 }
-/** Common prefix to be able to tell logged messages apart and filter them in devtools */
-const consPrefix = `[${_constants__WEBPACK_IMPORTED_MODULE_1__.scriptInfo.name}]`;
-const consPrefixDbg = `[${_constants__WEBPACK_IMPORTED_MODULE_1__.scriptInfo.name}/#DEBUG]`;
 /**
  * Logs all passed values to the console, as long as the log level is sufficient.
  * @param args Last parameter is log level (0 = Debug, 1/undefined = Info) - any number as the last parameter will be stripped out! Convert to string if they shouldn't be.

+ 0 - 64
src/dev/numKeysJumpTo.js

@@ -1,64 +0,0 @@
-(() => {
-  const timeSteps = 10; // includes 10 so the 9 key doesn't jump to the very end
-  function getX(timeKey, maxWidth) {
-    if(timeKey >= timeSteps)
-      return maxWidth;
-    return Math.floor(maxWidth / timeSteps) * timeKey;
-  }
-
-  console.log("scrollY", getUnsafeWindow().scrollY);
-
-  const elem = document.querySelector("tp-yt-paper-slider#progress-bar tp-yt-paper-progress#sliderBar");
-  const rect = getOffset(elem);
-
-  console.log("element rect", rect);
-
-  const x = getX(9, rect.width);
-  const y = rect.top - rect.height / 2;
-
-  console.log("x & y", x, y);
-
-  const evt = new MouseEvent("mousedown", {
-    clientX: x,
-    clientY: y,
-    layerX: x,
-    layerY: rect.height / 2,
-    target: elem,
-    bubbles: true,
-    view: getUnsafeWindow(),
-    shiftKey: false,
-    ctrlKey: false,
-    altKey: false,
-    metaKey: false,
-    button: 0,
-    buttons: 1,
-    which: 1,
-    isTrusted: true,
-    offsetX: 0,
-    offsetY: 0,
-  });
-
-  elem.dispatchEvent(evt);
-
-  function getOffset(el) {
-    var _x = 0;
-    var _y = 0;
-    const rect = el.getBoundingClientRect();
-    console.log("rect", rect);
-    while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
-      _x += el.offsetLeft - el.scrollLeft;
-      _y += el.offsetTop - el.scrollTop;
-      el = el.offsetParent;
-    }
-    return { top: _y, left: _x, width: rect.width, height: rect.height };
-  }
-})();
-
-function getUnsafeWindow() {
-  try {
-    return unsafeWindow;
-  }
-  catch(e) {
-    return window;
-  }
-}

+ 6 - 4
src/utils.ts

@@ -7,8 +7,14 @@ import * as resources from "../assets/resources.json" assert { type: "json" };
 
 let curLogLevel: LogLevel = 1;
 
+/** Common prefix to be able to tell logged messages apart and filter them in devtools */
+const consPrefix = `[${scriptInfo.name}]`;
+const consPrefixDbg = `[${scriptInfo.name}/#DEBUG]`;
+
 /** Sets the current log level. 0 = Debug, 1 = Info */
 export function setLogLevel(level: LogLevel) {
+  if(curLogLevel !== level)
+    console.log(consPrefix, "Setting log level to", level === 0 ? "Debug" : "Info");
   curLogLevel = level;
 }
 
@@ -24,10 +30,6 @@ function getLogLevel(args: unknown[]): number {
   return 0;
 }
 
-/** Common prefix to be able to tell logged messages apart and filter them in devtools */
-const consPrefix = `[${scriptInfo.name}]`;
-const consPrefixDbg = `[${scriptInfo.name}/#DEBUG]`;
-
 /**
  * Logs all passed values to the console, as long as the log level is sufficient.  
  * @param args Last parameter is log level (0 = Debug, 1/undefined = Info) - any number as the last parameter will be stripped out! Convert to string if they shouldn't be.