Last active
January 3, 2017 01:38
-
-
Save myfreeer/fdb5fabd7c2e02f72646eb1edc5bad76 to your computer and use it in GitHub Desktop.
为coolapk.com显示真实评分
This file contains hidden or 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 coolapk Real Rank | |
// @namespace myfreeer | |
// @version 0.5 | |
// @description coolapk.com显示真实评分 | |
// @author myfreeer | |
// @license GNU GPL v3 | |
// @downloadURL https://gist.github.com/myfreeer/fdb5fabd7c2e02f72646eb1edc5bad76/raw/coolapk-real-rank-babel.user.js | |
// @match http://*.coolapk.com/apk/* | |
// @match http://*.coolapk.com/game/* | |
// @match http://coolapk.com/apk/* | |
// @match http://coolapk.com/game/* | |
// @match https://*.coolapk.com/apk/* | |
// @match https://*.coolapk.com/game/* | |
// @match https://coolapk.com/apk/* | |
// @match https://coolapk.com/game/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var rank = 0, | |
ranks = [], | |
rankScore = document.querySelectorAll('.ex-apk-rank-score'), | |
rankStar = document.querySelectorAll('.ex-apk-rank-star > .big-star'); | |
for (var i = 1; i < 6; i++) { | |
var star = document.querySelectorAll('.star-' + i.toString()); | |
for (var j in star) { | |
if (star[j] && star[j].parentNode && star[j].parentNode.lastChild && star[j].parentNode.lastChild.className === "ex-apk-rank-percent" && !isNaN(parseInt(star[j].parentNode.lastChild.innerText))) { | |
ranks.push(i * parseInt(star[j].parentNode.lastChild.innerText)); | |
break; | |
} | |
} | |
} | |
if (ranks.length === 5) | |
for (var _i in ranks) { | |
rank += ranks[_i] / 100; | |
} | |
if (rank > 0) { | |
for (var _i2 in rankScore) { | |
if (rankScore[_i2]) { | |
rankScore[_i2].title = rankScore[_i2].innerText; | |
rankScore[_i2].innerText = rank.toString().length > 3 ? rank.toString().substring(0, 3) : rank; | |
} | |
} | |
for (var _i3 in rankStar) { | |
if (rankStar[_i3]) { | |
if (rankStar[_i3] && rankStar[_i3].className && rankStar[_i3].className.match(/big-star-(\d+)/) && rankStar[_i3].className.match(/big-star-(\d+)/)[1]) rankStar[_i3].title = rankStar[_i3].className.match(/big-star-(\d+)/)[1]; | |
rankStar[_i3].className = "big-star big-star-" + (rank >>> 0); | |
} | |
} | |
} | |
})(); |
This file contains hidden or 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 coolapk Real Rank | |
// @namespace myfreeer | |
// @version 0.5 | |
// @description coolapk.com显示真实评分 | |
// @author myfreeer | |
// @license GNU GPL v3 | |
// @downloadURL https://gist.github.com/myfreeer/fdb5fabd7c2e02f72646eb1edc5bad76/raw/coolapk-real-rank.user.js | |
// @match http://*.coolapk.com/apk/* | |
// @match http://*.coolapk.com/game/* | |
// @match http://coolapk.com/apk/* | |
// @match http://coolapk.com/game/* | |
// @match https://*.coolapk.com/apk/* | |
// @match https://*.coolapk.com/game/* | |
// @match https://coolapk.com/apk/* | |
// @match https://coolapk.com/game/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let rank = 0, | |
ranks = [], | |
rankScore = document.querySelectorAll('.ex-apk-rank-score'), | |
rankStar = document.querySelectorAll('.ex-apk-rank-star > .big-star'); | |
for (let i = 1; i < 6; i++) { | |
let star = document.querySelectorAll('.star-' + i.toString()); | |
for (let j in star) | |
if (star[j] && star[j].parentNode && star[j].parentNode.lastChild && star[j].parentNode.lastChild.className === "ex-apk-rank-percent" && !isNaN(parseInt(star[j].parentNode.lastChild.innerText))) { | |
ranks.push(i * parseInt(star[j].parentNode.lastChild.innerText)); | |
break; | |
} | |
} | |
if (ranks.length === 5) | |
for (let i in ranks) rank += ranks[i] / 100; | |
if (rank > 0) { | |
for (let i in rankScore) | |
if (rankScore[i]) { | |
rankScore[i].title = rankScore[i].innerText; | |
rankScore[i].innerText = rank.toString().length > 3 ? rank.toString().substring(0, 3) : rank; | |
} | |
for (let i in rankStar) | |
if (rankStar[i]) { | |
if (rankStar[i] && rankStar[i].className && rankStar[i].className.match(/big-star-(\d+)/) && rankStar[i].className.match(/big-star-(\d+)/)[1]) rankStar[i].title = rankStar[i].className.match(/big-star-(\d+)/)[1]; | |
rankStar[i].className = "big-star big-star-" + (rank >>> 0); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment