Cryptact レイアウト stylus style JS Tampermonkey

2025-02-27 CryptactのWEB版のレイアウトを変更。

 

Cryptact表示用でブラウザを分けるか。Operaでも使うことにしよう。

レイアウトを変えるからね。

Grok3さんと相談して作成。

要は表が見切れる。→Stylusで変更。



/* テーブルの列幅を自動調整して見切れないようにする */
table {
  table-layout: auto !important;
  word-wrap: break-word !important;
  white-space: normal !important;
}

/* テキストを折り返して表示する */
td, th {
  white-space: normal !important;
  word-break: break-word !important;
}

/* 長いテキストをスクロール可能にする場合 */
td {
  overflow-x: auto !important;
  max-width: 200px; /* 必要に応じて調整 */
}







見出しが見えなくなって不便 → Javascriptで対応(Tampermonkey)



// ==UserScript==
// @name         Cryptact Fixed Header
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Fix table header on scroll for Transactions page only
// @author       You
// @match        https://grid.cryptact.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function createFixedHeader() {
        const currentUrl = location.href;
        const isTransactionsPage = currentUrl.startsWith('https://grid.cryptact.com/transactions/');

        // Transactionページ以外で既存ヘッダーを削除
        if (!isTransactionsPage) {
            const existingHeader = document.querySelector('.fixed-header');
            if (existingHeader) {
                existingHeader.remove();
                console.log('Removed fixed header on non-Transactions page:', currentUrl);
            }
            return;
        }

        const table = document.querySelector('.table--hoverable');
        if (!table) {
            console.log('Error: .table--hoverable not found');
            return;
        }
        const thead = table.querySelector('thead tr');
        if (!thead) {
            console.log('Error: thead tr not found within .table--hoverable');
            return;
        }
        console.log('Found thead! Creating fixed header on Transactions page.');

        const existingHeader = document.querySelector('.fixed-header');
        if (existingHeader) existingHeader.remove();

        const fixedHeader = thead.cloneNode(true);
        fixedHeader.className = 'fixed-header';
        fixedHeader.style.position = 'fixed';
        fixedHeader.style.top = '140px';
        fixedHeader.style.backgroundColor = '#f0f0f0';
        fixedHeader.style.zIndex = '10';
        const tableRect = table.getBoundingClientRect();
        fixedHeader.style.left = tableRect.left + 'px';
        fixedHeader.style.width = tableRect.width + 'px';
        document.body.appendChild(fixedHeader);

        fixedHeader.style.display = 'none';

        function syncWidths() {
            const ths = thead.querySelectorAll('th');
            const fixedThs = fixedHeader.querySelectorAll('th');
            const tbodyRows = table.querySelectorAll('tbody tr');
            const tds = tbodyRows[0] ? tbodyRows[0].querySelectorAll('td') : [];
            fixedThs.forEach((th, index) => {
                if (tds[index]) th.style.width = getComputedStyle(tds[index]).width;
            });
            fixedHeader.style.left = table.getBoundingClientRect().left + 'px';
            fixedHeader.style.width = table.getBoundingClientRect().width + 'px';
        }

        syncWidths();
        window.addEventListener('resize', syncWidths);
        window.addEventListener('scroll', () => {
            const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
            fixedHeader.style.display = scrollTop > 200 ? 'table-row' : 'none';
            syncWidths();
        });
    }

    // 初回実行とページ変更検知
    setTimeout(() => {
        createFixedHeader();
    }, 5000); // 5秒待機

    let lastUrl = location.href;
    setInterval(() => {
        if (lastUrl !== location.href) {
            lastUrl = location.href;
            setTimeout(() => {
                createFixedHeader();
            }, 5000); // 5秒待機
            console.log('URL changed, recreated fixed header.');
        }
    }, 500); // 0.5秒ごとにURLチェック
})();

scrcpy wifi adb 5555 ip bat

 

https://pc.mikeneko.cute.bz/x/wp/2019/06/26/vysor%e3%82%a2%e3%83%b3%e3%83%89%e3%83%ad%e3%82%a4%e3%83%89%e3%81%ae%e3%83%aa%e3%83%a2%e3%83%bc%e3%83%88%e3%83%87%e3%82%b9%e3%82%af%e3%83%88%e3%83%83%e3%83%97wifi%e7%b5%8c%e7%94%b1/?hilite=%27adb%27

Get your device IP address (in Settings → About phone → Status).
adb tcpip 5555
adb connect DEVICE_IP:5555

 

ConnectAndroid_wifi.bat

scrcpyを使って接続することにします。

android側アプリ。IPを表示します。

ConnectAndroid_wifi.bat

@echo off
d:
cd "D:\Program\scrcpy\"

dir 

echo "ConnectAndroid_wifi.bat Start"

:INPUT_CHECK
SET INPUTSTR=
SET /P INPUTSTR="Android側ローカルIPを入力してください。
IF "%INPUTSTR%"=="" GOTO :INPUT_CHECK
echo IP="%INPUTSTR%"

call adb.exe tcpip 5555
call adb.exe connect "%INPUTSTR%":5555


call scrcpy.exe

ECHO 完了
pause

 

作っていてたまたまVysorと同時につながったので比較しました。

 

左がVysor,右がscrcpyです。

解像度がscrcpyの方が高いようです。

 

目覚まし シェルスクリプト Timeout puppy

一定時間後にモニタをオフ。指定時間にプログラムを実行。



#!/bin/bash

function SetWakeDayAfter() {
  para1=""
  echo "----------------------------"
  echo "wake日時を選択してください。。"
  echo "0=today,1=+1day,2=+2day"
  read input
  
  if [ $input = 0 ] ; then
      para="today"
  elif [ $input = 1 ] ; then
       para="+1 days"
#    echo "  スクリプトを実行します."
#    return $input
  elif [ $input = 2 ] ; then
       para="+2 days"
#    echo "  スクリプトを終了します."
#    exit 1
  else
    echo "有効値を入力してください"
    SetWakeTime
  fi
#  echo $para
  return $input

}

function ConfirmExecution() {

  echo "----------------------------"
  echo "一定時間経過後電源を切ります。"
  echo "何分後に電源を切りますか?"
  read input

  if [ -z $input ] ; then

    echo "数値を入力してください(255まで)。no=終了します"
    ConfirmExecution

  #elif [ $input = 'yes' ] || [ $input = 'YES' ] || [ $input = 'y' ] ; then
  elif [[ "$input" =~ ^[0-9]+$ ]] ; then
    echo "  スクリプトを実行します."
    return $input
  elif [ $input = 'no' ] || [ $input = 'NO' ] || [ $input = 'n' ] ; then
    echo "  スクリプトを終了します."
    exit 1
  else
    echo "数値を入力してください。"
    ConfirmExecution
  fi

}

keizoku=999
while [ $keizoku -gt 0 ]
do
  #keizoku=$keizoku -1
  keizoku=$(($keizoku - 1))
  echo "keizoku="$keizoku

	SetWakeDayAfter
	KeikaNichiji=$?

	echo "----------------------------"
	echo $KeikaNichiji"日後に復帰します"
	#date +%Y-%m-%d" 04:30:00" --date '+1 days'
	#date +%Y-%m-%d" 04:30:00" --date "+"$KeikaNichiji" days"
	WakeTime=$(date +%Y-%m-%d" 04:00:00" --date "+"$KeikaNichiji" days")
	echo $WakeTime
	#$(date +%s -d "2021-09-30 04:30:00")
	#date +%s -d "2021-10-01 04:30:00"
	#echo "2021-10-03"
	#date +%s -d "2021-10-03 04:30:00"
	#date +%s -d "2021-10-03 04:30:00"
	#date +%s -d $"2021-10-03 04:30:00"
	WakeTimeSecond=$(date +%s -d """$WakeTime""")
	echo $WakeTimeSecond


	#firefox "https://www.youtube.com/watch?v=ncfViXHwlcE" &


	# シェルスクリプトの実行を継続するか確認します。
	ConfirmExecution
	Remain=$?

	echo "----------------------------"
	echo $Remain"分後に電源を切ります"


	start=1
	#end=120
	#echo "please wait $end seconds"
	  while [[ $start -le $Remain ]]; do
		echo $(($Remain-$start))
	#	xdotool mousemove 300 $start
		sleep 1m
	#    sleep 5s
	#	xdotool mousemove $start 300
	 #   sleep 5s
		start=$(($start+1))
	  done


	#sleep 120m
	echo "電源を切ります。"
	sleep 1m
	#poweroff
	pgrep firefox | xargs kill -9
	sleep 1m
	$WakeTimeSecond
	#sudo /usr/sbin/rtcwake -m mem -t $(date +%s -d "2021-09-30 04:30:00")
	sudo /usr/sbin/rtcwake -m mem -t $WakeTimeSecond
	#date +%Y-%m-%d" 04:30:00" --date "+"$KeikaNichiji" days"
	#sudo /usr/sbin/rtcwake -m mem -t $(date +%s -d "2021-09-30 04:30:00")

	sleep 1m
	firefox "https://www.youtube.com/watch?v=P1fYUdJJ-20" &
	#sleep 1m

	start=1
	Remain=60
	#end=120
	#echo "please wait $end seconds"
	  while [[ $start -le $Remain ]]; do
		echo $(($Remain-$start))
		xdotool mousemove 300 $start
	 #   sleep 1m
		sleep 30s
		echo "画面キープ中、Remain="$Remain
		xdotool mousemove $start 300
		sleep 30s
		start=$(($start+1))
	  done

done