Created
December 6, 2018 15:53
-
-
Save blahgeek/b86dcf744058b181f5f37af520ebb20c 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 QiXinHelper | |
// @namespace http://blahgeek.com/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author BlahGeek | |
// @match https://www.qixin.com/company/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var decrypt = function(s) { | |
var ENC_DICT = '5809136427'; | |
var ret = ''; | |
for (var i = 0 ; i < s.length ; i += 1) { | |
var x = s.charCodeAt(i) - '0'.charCodeAt(0); | |
if (x >= 0 && x <= 9) | |
ret += ENC_DICT[x]; | |
else | |
ret += s[i]; | |
} | |
return ret; | |
}; | |
var elems = Array.prototype.slice.call(document.getElementsByClassName('qxb-num')); | |
for (var i = 0 ; i < elems.length ; i += 1) { | |
var elem = elems[i]; | |
elem.innerText = decrypt(elem.innerText); | |
elem.setAttribute('class', ''); | |
} | |
console.log(elems); | |
var sum_elem = document.evaluate("//td[text()='注册资本']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.nextSibling; | |
var sum = Number.parseFloat(sum_elem.innerText); | |
var title_elem = document.evaluate("//th[text()='认缴出资(金额/时间)']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
var idx = Array.prototype.slice.call(title_elem.parentElement.children).indexOf(title_elem); | |
console.log(idx); | |
elems = Array.prototype.slice.call(title_elem.parentElement.parentElement.parentElement.getElementsByTagName('tr')); | |
console.log(elems); | |
for (var i = 1 ; i < elems.length ; i += 1) { | |
var elem = elems[i].children[idx]; | |
var percent = Number.parseFloat(elem.innerText) / sum * 100; | |
elem.innerText += ' (' + percent.toFixed(2) + '%)'; | |
console.log(elem.innerText); | |
} | |
// Your code here... | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment