Skip to content

Commit

Permalink
Fixed roundDown bug
Browse files Browse the repository at this point in the history
  • Loading branch information
j14-c committed Nov 28, 2021
1 parent bb8def7 commit f51258c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Extensions/UserScript/Return Youtube Dislike.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function doXHR(opts) {
if (typeof GM_xmlhttpRequest === 'function') {
return GM_xmlhttpRequest(opts);
}
if (typeof GM !== 'undefined') /*This will prevent from throwing "Uncaught ReferenceError: GM is not defined"*/{
if (typeof GM !== 'undefined') /*This will prevent from throwing "Uncaught ReferenceError: GM is not defined"*/ {
if (typeof GM.xmlHttpRequest === 'function') {
return GM.xmlHttpRequest(opts);
}
Expand Down Expand Up @@ -194,7 +194,8 @@ function isVideoLoaded() {

function roundDown(num) {
if (num < 1000) return num;
const decimal = Math.floor(Math.log10(num) - 1);
const int = Math.floor(Math.log10(num) - 2);
const decimal = int + (int % 3 ? 1 : 0);
const value = Math.floor(num / 10 ** decimal);
return value * (10 ** decimal);
}
Expand Down
3 changes: 2 additions & 1 deletion Extensions/chrome/return-youtube-dislike.script.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@

function roundDown(num) {
if (num < 1000) return num;
const decimal = Math.floor(Math.log10(num) - 1);
const int = Math.floor(Math.log10(num) - 2);
const decimal = int + (int % 3 ? 1 : 0);
const value = Math.floor(num / 10 ** decimal);
return value * (10 ** decimal);
}
Expand Down
3 changes: 2 additions & 1 deletion Extensions/firefox/return-youtube-dislike.script.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ function isVideoLoaded() {

function roundDown(num) {
if (num < 1000) return num;
const decimal = Math.floor(Math.log10(num) - 1);
const int = Math.floor(Math.log10(num) - 2);
const decimal = int + (int % 3 ? 1 : 0);
const value = Math.floor(num / 10 ** decimal);
return value * (10 ** decimal);
}
Expand Down

0 comments on commit f51258c

Please sign in to comment.