Cracking Banner

Moves cracking stats info into the top banner

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Cracking Banner
// @namespace    https://www.torn.com/
// @version      1.0.1
// @match        https://www.torn.com/page.php?sid=crimes*
// @author       M00SE
// @description  Moves cracking stats info into the top banner
// @license      MIT
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  function clean(text) {
    return (text || '').replace(/\s+/g, ' ').trim();
  }

  function getRows(stats) {
    return Array.from(stats.querySelectorAll('.statistic___zH4MM')).map(row => {
      const label = clean(row.querySelector('.label___k42ll')?.textContent);
      const value = clean(row.querySelector('.value___FmWPr')?.textContent);
      return { label, value };
    }).filter(row => row.label && row.value);
  }

  function drawPanel(panel, rows) {
    panel.innerHTML = rows.map(row => `
      <div style="display: flex; justify-content: space-between; gap: 8px; line-height: 1.25;">
        <span style="color: #ccc;">${row.label}</span>
        <span style="color: #fff; font-weight: bold; text-align: right;">${row.value}</span>
      </div>
    `).join('');
  }

  setInterval(() => {
    const stats = document.querySelector('.statistics___jmn48:not(#cracking-stats-copy)');
    const banner = document.querySelector('.currentCrime___MN0T1 > .bannerArea___bnT7m');

    if (!stats || !banner) return;

    let panel = document.querySelector('#cracking-stats-copy');

    if (!panel) {
      panel = document.createElement('div');
      panel.id = 'cracking-stats-copy';

      panel.setAttribute(
        'style',
        'position: absolute; top: 50%; left: 24%; transform: translate(-50%, -50%); z-index: 999999; background: rgba(0,0,0,0.85); color: white; padding: 6px 8px; width: 260px; max-width: 42%; box-sizing: border-box; font: 11px Arial, sans-serif; border-radius: 4px;'
      );

      banner.style.position = 'relative';
      banner.appendChild(panel);
    }

    drawPanel(panel, getRows(stats));
  }, 1000);
})();