Skip to content

Instantly share code, notes, and snippets.

@djosix
Created May 30, 2020 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djosix/7ac6ef0a9d6cec55150881dea3e60eeb to your computer and use it in GitHub Desktop.
Save djosix/7ac6ef0a9d6cec55150881dea3e60eeb to your computer and use it in GitHub Desktop.
// ==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