basyura's blog

あしたになったらほんきだす。

Vivaldi - Windows の場合だけ特定のスタイルを適用する

Stylus を使ってよく見るサイトは独自スタイルを適用することがよくある。ヘッダー、フッター、サイドバーを消すとか。OS に依存しない場合はいいけど、レンダリングやディスプレイによって微妙に変えたい場合に対応できない。css で OS を判断して分岐できないから。Dropbox と連携して複数環境 (と言っても二台) で Stylus の設定を同期しているので、windows では適用したいけど mac では適用したくないなどがある。特にフォント周り。それぞれの os で同期したときだけ有効と無効を切り替えればいいかと運用してたけど、都度気になってしまうので効率が悪い。Stylus に同期しない設定を追加するような機能追加をすればいいかと思って実装していたけど、npm の実装に依存して対応できなさそうなので諦めた。PR 作るにしてもテストできる範囲は限られてるし。

Stylus じゃなくて Tampermonkey で個別に対応すればいいことに気がつく。以下。

// ==UserScript==
// @name         All Windows
// @namespace    http://tampermonkey.net/
// @version      2025-05-18
// @description  try to take over the world!
// @author       You
// @match        http://*/*
// @match        https://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const style = document.createElement('style');
    style.className = 'self-tampermonkey';
    style.textContent = `
    設定したいスタイル
  `;

    // body がまだ無い場合に備えて
    function insertStyleWhenReady() {
        if (document.body) {
            document.body.insertAdjacentElement("afterend", style);
        } else {
            new MutationObserver((mutations, observer) => {
                if (document.body) {
                    document.body.insertAdjacentElement("afterend", style);
                    observer.disconnect();
                }
            }).observe(document.documentElement, { childList: true, subtree: true });
        }
    }

    insertStyleWhenReady();
})();

また便利になった。

`=` フォルダが作られる

git pull すると = フォルダが作られる。

=
+ system-commandline-sentinel-files
  + dotnet-suggest-registration-git-credential-manager, Version=2.6.1

"dotnet-suggest-registration-git-credential-manager, Version=2.6.1" はファイルで 以下の内容が出力されている。

Exception during registration:
System.ComponentModel.Win32Exception (0x80004005): 指定されたファイルが見つかりません。
   場所 System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   場所 System.Diagnostics.Process.Start()
   場所 System.CommandLine.Invocation.Process.StartProcess(String command, String args, String workingDir, Action`1 stdOut, Action`1 stdErr, ValueTuple`2[] environmentVariables)
   場所 System.CommandLine.Builder.CommandLineB

git-credential-manager が何かしら作用しているようで

DOTNET_SYSTEM_COMMANDLINE_DISABLE_SUGGEST=1

を環境変数に定義することで回避できるとあるけど改善できない。

/etc/profile を編集してみる

ORIGINAL_TMP="${ORIGINAL_TMP:-${TMP}}"
ORIGINAL_TEMP="${ORIGINAL_TEMP:-${TEMP}}"
#unset TMP TEMP
#tmp=$(exec cygpath -w "$ORIGINAL_TMP" 2> /dev/null)
#temp=$(exec cygpath -w "$ORIGINAL_TEMP" 2> /dev/null)
#TMP="/tmp"
#TEMP="/tmp"
case "$TMP" in *\\*) TMP="$(cygpath -m "$TMP")";; esac
case "$TEMP" in *\\*) TEMP="$(cygpath -m "$TEMP")";; esac
test -d "$TMPDIR" || test ! -d "$TMP" || {
  TMPDIR="$TMP"
  export TMPDIR
}

ORIGINAL_TMP="${ORIGINAL_TMP:-${TMP}}"
ORIGINAL_TEMP="${ORIGINAL_TEMP:-${TEMP}}"
unset TMP TEMP
tmp=$(exec cygpath -w "$ORIGINAL_TMP" 2> /dev/null)
temp=$(exec cygpath -w "$ORIGINAL_TEMP" 2> /dev/null)
TMP="/tmp"
TEMP="/tmp"
case "$TMP" in *\\*) TMP="$(cygpath -m "$TMP")";; esac
case "$TEMP" in *\\*) TEMP="$(cygpath -m "$TEMP")";; esac
test -d "$TMPDIR" || test ! -d "$TMP" || {
  TMPDIR="$TMP"
  export TMPDIR
}

改善した。ついでに cgo を使う mattn/go-sqlite3 を使ったビルドをする際も似たような感じ (tmp ディレクトリを認識してない) でエラーが出てたのも改善された。

進撃の巨人

読み返し。単行本が発売されたタイミングで都度読んでいた時は意味が分からんとなって流し読みになっていたけど、改めて読むと分かる。最近だと ChatGPT で質問して理解を深められるのもいい。

ChatGPT.app で Enter 送信したくない

いつまでこの戦いを続けるのか。

  • 入力中の Ctrl+Enter は GoogleIME の予測変換で使う
  • 未入力中の Ctrl+Enter で送信したい
  • Enter は改行したい

Web 版は Tampermonkey で対応したけど (たまに動かくなる) アプリ版は厳しそう。 Enter で誤送信して萎えるよりは Shift+Entetr 送信で妥協する。

GoogleIME キー設定

Composition    Shift Enter     Commit
Conversion     Shift Enter     Commit

Karabiner-Elements 設定

{
  "description": "ChatGPT : Enter to Shift+Enter",
  "manipulators": [
    {
      "type": "basic",
      "from": { "key_code": "return_or_enter" },
      "to": [{ "key_code": "return_or_enter", "modifiers": ["shift"] }],
      "conditions": [
        { "type": "frontmost_application_if", "bundle_identifiers": ["^com\\.openai\\.chat$"] }
      ]
    }
  ]
},
{
  "description": "ChatGPT : Shift+Enter to Enter",
  "manipulators": [
    {
      "type": "basic",
      "from": { "key_code": "return_or_enter", "modifiers": { "mandatory": ["shift"] }
      },
      "to": [{ "key_code": "return_or_enter" }],
      "conditions": [
        { "type": "frontmost_application_if", "bundle_identifiers": ["^com\\.openai\\.chat$"] }
      ]
    }
  ]
}

で運用していたけど、Shift + Enter 送信の癖が変につくと他で誤爆しそうなので Ctrl+m で送信するようにして試している。

{
  "description": "ChatGPT : control+m to Enter",
  "manipulators": [
    {
      "type": "basic",
      "from": {
        "key_code": "m",
        "modifiers": {
          "mandatory": ["control"]
        }
      },
      "to": [{ "key_code": "return_or_enter" }],
      "conditions": [
        {
          "type": "frontmost_application_if",
          "bundle_identifiers": ["^com\\.openai\\.chat$"]
        }
      ]
    }
  ]
}

cVim - color-scheme

color-scheme に dark を指定してる場合は iframe 内の html にも指定しないと透過されないという知見を得た。

cVim の更新が止まったので fork して manifest v3 対応して、趣味でゴリゴリいじってる。楽しい。cVim がないと仕事も趣味も何もできない (効率が著しく悪化する) ので、代替となるイイ感じの拡張が出てくるようなことがない限りは死ぬまで弄り続けることになるんじゃないかと思う (たぶん、はずれる)。

cVim はページを読み込んだ際に iframe を差し込み、拡張用の cmdline_frame.html を読み込む。 ページ上で : を押下すると iframe が表示されて vim のコマンドライン領域相当として表示される。これがダークモードを設定したサイトの場合に cmdline_frame.html が透過されず全体が真っ白に表示されていた。

サイトの color-scheme に dark が設定されている場合は cmdline_frame.html にも color-scheme:dark を指定するように修正した。

Vivaldi - カスタム css

MacType との相性が悪いのかタブの文字が微妙にボケるのでスタイルを変更。変えたところでボケるんだけど、ボケても気にならない程度になって・・・ないかな。

指定したフォルダに custom.css を配置。

.tab-header {
  text-shadow: transparent 0px 0px 0px, rgba(0, 0, 0, 0.1) 0px 0px 0px !important;
  font-size: 11px;
  font-weight: 500px !important;
  font-family: "BIZ UDPGothic";
  -webkit-font-smoothing: antialiased;
  color: black;
}