Raw Source
Dizy / Behash Helper 哈希宝界面辅助脚本

// ==UserScript==
// @name         Behash Helper 哈希宝界面辅助脚本
// @icon         http://behash.com/favicon.ico
// @namespace    https://dizy.cc/
// @license      MIT
// @version      0.1.3
// @description  哈希宝用户界面辅助脚本,用当前哈希价格计算并显示估计人民币收入。Show money in current currency value when you are using Behash.com
// @author       Dizy
// @updateURL https://openuserjs.org/meta/Dizy/Behash_Helper_哈希宝界面辅助脚本.meta.js
// @downloadURL https://openuserjs.org/install/Dizy/Behash_Helper.user.js
// @copyright    2021, Dizy (https://openuserjs.org/users/Dizy)
// @require      tampermonkey://vendor/jquery.js
// @match        http*://*.behash.com/*
// @grant        unsafeWindow
// ==/UserScript==

/*global $*/
/*jshint esversion: 6 */
(function () {
  'use strict';

  function modUserPage() {
    let priceStr = $("div:contains('哈希单价'):not(:has(> div)):not(:has(> ul))").next().next().text();
    let price = Number(priceStr.match(/\d+\.\d+/)[0]);
    let $hashSizeCol = $("div:contains('可提现数量'):not(:has(> div)):not(:has(> ul))").next().next();
    let hashSize = Number($hashSizeCol.text().match(/\d+\.\d+/)[0]);
    let money = price * hashSize;
    $hashSizeCol.html($hashSizeCol.text() + `<br> ≈ ${money.toFixed(2)} 元`);

    let $incomeTodayCol = $("div:contains('今日收益'):not(:has(> div)):not(:has(> ul))").next().next();
    let incomeTodayMatches = $incomeTodayCol.text().match(/\d+\.\d+/g);
    let incomeHashSizeToday = Number(incomeTodayMatches[0]);
    let incomeRMBToday = Number(incomeTodayMatches[1]);
    let moneyToday = price * incomeHashSizeToday + incomeRMBToday;
    $incomeTodayCol.html($incomeTodayCol.text() + `<br> ≈ 共 ${moneyToday.toFixed(2)} 元`);

    let $incomeYesterdayCol = $("div:contains('昨日收益'):not(:has(> div)):not(:has(> ul))").next().next();
    let incomeYesterdayMatches = $incomeYesterdayCol.text().match(/\d+\.\d+/g);
    let incomeHashSizeYesterday = Number(incomeYesterdayMatches[0]);
    let incomeRMBYesterday = Number(incomeYesterdayMatches[1]);
    let moneyYesterday = price * incomeHashSizeYesterday + incomeRMBYesterday;
    $incomeYesterdayCol.html($incomeYesterdayCol.text() + `<br> ≈ 共 ${moneyYesterday.toFixed(2)} 元`);
  }

  function registerHooks() {
    if (window.location.pathname === '/user') {
      modUserPage();
    }
  }

  registerHooks();

})();