Created
May 30, 2020 15:46
-
-
Save djosix/7ac6ef0a9d6cec55150881dea3e60eeb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name JAV101 Likes Ratio | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://v.jav101.com/* | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
function s2n(s) { | |
let g = /(?:(?<k>\d+)k)?(?<n>\d+)?/i.exec(s).groups; | |
return 0 + (g.n ? Number(g.n) : 0) + (g.k ? Number(g.k) * 1000 : 0); | |
} | |
$('.videoBox-action').each((i, e) => { | |
e = $(e); | |
let views = e.find('.views .number'); | |
let likes = e.find('.likes .number'); | |
let ratio = Math.round(1000 * s2n(likes.text()) / s2n(views.text())) / 100; | |
likes.text(ratio); | |
if (ratio > 1.5) likes.css('color', '#F00').css('font-weight', 'bold'); | |
else if (ratio > 1.0) likes.css('color', '#C00').css('font-weight', 'bold'); | |
else if (ratio > 0.7) likes.css('color', '#A44'); | |
else if (ratio > 0.3) likes.css('color', '#744'); | |
else likes.css('color', '#444'); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment