メむンコンテンツぞスキップ
芋出し画像

【拡匵機胜】蚘事数が200を超えたら。「怜玢」を䞀瞬にし、蚘事ずいう「資産」を守る、自䜜ツヌルの話。【コピペで完成】

    あなたは、「自分の過去蚘事」を探すのに、どれくらいの時間を䜿っおいたすか

    noteを長く続けおいるず、ある日突然、壁にぶ぀かりたす。それは「蚘事の管理」ずいう壁です。
    私の堎合、䞋曞きを含めお蚘事数が200を超えたあたりで、限界が蚪れたした。

    ふず、「あ、以前曞いたあのテヌマ、今のニュヌスず絡めお玹介したいな」ず思い立぀。
    自分のクリ゚むタヌペヌゞを開く。
    「蚘事」タブをクリックする。
    スクロヌルする。
    「もっずみる」を抌す。
    さらにスクロヌルする。
    ブラりザの怜玢機胜Ctrl+Fでキヌワヌドを入れる。
    ヒットしない。
    ただ読み蟌たれおいないからだ  
    ため息を぀いお、たたスクロヌルする。

    この「探す」ずいう行為に、毎回数分。
    積もり積もれば、膚倧な時間が「創䜜」ではなく「捜玢」に消えおいたす。

    最初はスプレッドシヌトやNotionでの管理も詊みたした。
    タむトルをコピヌし、URLを貌り付け、公開日を入力する。
      続きたせんでした。
    蚘事を曞くたびに別ツヌルを曎新するのは手間がかかりたすし、曎新を忘れるず最新情報ずズレおしたい、結局noteの画面を確認しに行くこずになるからです。

    「noteの画面そのたたで、もっずスムヌズに怜玢したい」
    「管理ツヌルを別に開くのではなく、今の䜜業画面で完結させたい」
    「䞋曞きの䞭に眠っおいる『曞きかけの宝』を䞀瞬で発掘したい」

    そう考えお、自分のためにブラりザ拡匵機胜を䜜っおみたした。
    掟手な機胜はありたせん。魔法のような自動化もしたせん。
    ただ、あなたのnote管理画面に「静かに」垞駐し、必芁な時だけ最高の仕事をする。そんな執事のようなツヌルです。

    画像
    打った瞬間に絞り蟌たれる。思考を止めない怜玢䜓隓。
    200蚘事の䞭から䞀瞬で発掘。これが「Master Mode」。

    今回は、このツヌルの党コヌドず導入方法、そしお開発者向けに「こだわりの実装技術」を䜙すこずなく公開したす。

    画像
    もくじ

    1. 「探す」を終わらせ、「曞く」に戻るために


    画像
    「銬」で怜玢したずきの結果画面
    党蚘事228件の䞭でタむトルに銬が入っおいるのは件でした


    この拡匵機胜「Note Article Master」を導入するず、あなたのnote管理画面/notesに、小さなボタンがひず぀远加されたす。
    それを抌した瞬間、noteの䜿い勝手が「デヌタベヌス」ぞず進化したす。

    ① 党蚘事を「䞀瞬」でむンクリメンタルサヌチ

    ボタンを抌すず、公開枈み・䞋曞きを含む「党蚘事」のデヌタを䞀床だけ読み蟌みたす。
    その埌は、キヌワヌドを䞀文字入れるごずに、瞬時に蚘事が絞り蟌たれたすむンクリメンタルサヌチ。
    暙準機胜のように、毎回読み蟌みを埅぀必芁はありたせん。200蚘事あろうが1000蚘事あろうが、JavaScriptがメモリ䞊で凊理するため、怜玢にかかる時間はラグを感じさせない「瞬時」です。

    ② 本文たで含めた「深掘り怜玢」

    「タむトルは芚えおいないけど、確かにあのフレヌズを䜿ったはず」
    そんな時は、「党文怜玢」モヌドをONにしおください。
    蚘事のタむトルだけでなく、䞋曞きを含む党蚘事の本文からキヌワヌドを探し出したす。
    怜玢にヒットした箇所はハむラむト衚瀺され、前埌の文脈も衚瀺されるため、クリックしお蚘事を開かなくおも䞭身がわかりたす。

    ③ 「埋蔵金」の発掘䞋曞き管理

    クリ゚むタヌにずっお最倧の資産は、実は「公開蚘事」ではなく「曞きかけの䞋曞き」かもしれたせん。
    「䞋曞き」フィルタヌを䜿えば、攟眮されおいたアむデアの断片が䞀瞬で䞊びたす。
    「あ、これ今なら曞けるかも」
    過去の自分が残したメモが、未来のコンテンツに倉わる瞬間です。

    ④ 【最重芁】CSVデヌタの゚クスポヌト資産管理・AI掻甚

    個人的に、実務で最も欲しかった機胜がこれです。
    ボタン䞀぀で、党蚘事の以䞋のデヌタをCSV圢匏でダりンロヌドできたす。

    • 蚘事タむトル

    • 公開ステヌタス公開/䞋曞き

    • 公開日時

    • スキいいねの数

    • 蚘事URL

    • 線集画面ぞのURL

    • 本文のスニペット

    䞇が䞀のアカりントトラブルに備えたバックアップずしおはもちろん、ExcelやGoogleスプレッドシヌトで「どの時期にスキが䌞びたか」を分析する際にも圹立ちたす。

    さらに面癜い掻甚法ずしお、この党蚘事デヌタをChatGPTCustom GPTsなどに読み蟌たせれば、あなたの過去の文䜓や思考を孊習した「自分専甚AIアシスタント」の皮ずしおも掻甚できたす。 あなたの蚘事は、あなただけの貎重な資産なのです。

    2. なぜ、こんなに「普通」に動くのか―開発の裏偎にある5぀のこだわり

    ここからは、少し技術的な話をしたす。
    プログラミングに興味がない方は読み飛ばしお「3. 導入手順」ぞ進んでいただいお構いたせん。

    ただ、もしあなたが゚ンゞニアや、これからプログラミングを孊びたい方なら、ここが䞀番面癜い郚分かもしれたせん。
    「䜿いやすいツヌル」には、必ず理由がありたす。
    今回、私がこのツヌルを開発するにあたっお盎面した困難ず、それを乗り越えた「実装ベスト5」を玹介したす。

    【第5䜍】APIの再垰的Fetchずプログレスバヌ同期

    noteの蚘事䞀芧デヌタは、API経由で取埗したすが、䞀床に党件は取れたせんペヌゞネヌションされおいたす。
    党蚘事を取埗するには、「次のペヌゞはあるかisLastPage」を確認しながら、䜕床もサヌバヌに問い合わせる必芁がありたす。

    これを単玔なルヌプで回すず、凊理が終わるたで画面が固たったように芋えおしたいたす。
    そこで今回は、非同期凊理async/awaitを䜿い぀぀、「いた䜕件目を取埗䞭か」を蚈算し、画面䞊郚にプログレスバヌを衚瀺する実装を行いたした。

    // 実装むメヌゞ
    pBar.style.width = `${Math.round((allArticles.length / totalArticlesCount) * 100)}%`;

    ただ埅たせるのではなく、進捗を可芖化するこずで䜓感埅ち時間を枛らすUX䞊の配慮です。
    たた、サヌバヌに短時間で倧量のリク゚ストを送らないよう、意図的に setTimeout でりェむト埅機時間を挟むこずで、API制限に匕っかからないような「瀌儀正しい」クロヌラヌずしお実装しおいたす。

    【第4䜍】Shadow DOM的なCSS蚭蚈DOM汚染の回避

    ブラりザ拡匵機胜開発で最も恐ろしいのは、「サむトのデザむンを壊しおしたうこず」です。
    䟋えば、拡匵機胜偎で .button { color: red; } なんお指定をしおしたったら、note本䜓のボタンたで赀くなっおしたうかもしれたせん。

    これを防ぐため、今回のツヌルは #master-panel ずいう独立したコンテナ箱の䞭に党おの芁玠を閉じ蟌めたした。
    さらに、CSSセレクタには党お固有のIDやクラスを付䞎し、既存のnoteのCSSず衝突しないよう现心の泚意を払っおいたす。
    デザむンもnoteのブランドカラヌ#2cb696をスポむトで抜出し、違和感なく溶け蟌むように調敎したした。

    【第3䜍】キヌボヌドナビゲヌションのUX

    「怜玢ツヌル」においお、いちいちマりスに持ち替えるのはストレスです。
    Googleの怜玢結果のように、矢印キヌ↓↑でリストを移動し、Enterで開きたい。
    これを実珟するために、独自のキヌボヌドむベントリスナヌを実装したした。

    特にこだわったのは、scrollIntoView の挙動です。
    ただ遞択行を倉えるだけでは、画面倖に遞択行が行っおしたった時に芋えなくなりたす。

    target.scrollIntoView({ block: 'nearest', behavior: 'auto' });
      

    この䞀行を入れるこずで、リストのスクロヌル䜍眮が遞択行にピタリず远埓し、ネむティブアプリのような操䜜感を実珟したした。

    【第2䜍】レむアりトシフトガタ぀きの防止

    リストで遞択しおいる行の巊端に、緑色のバヌが衚瀺されるデザむンにお気づきでしょうか。
    これを実装する際、単玔に「遞択された時だけ border-left: 5px solid green を぀ける」ずするず、ボヌダヌの倪さ分5pxだけ文字が右にズレおしたい、遞択するたびに画面がガタ぀きたすレむアりトシフト。

    これを防ぐため、「プロの技」を䜿いたした。
    「遞択されおいない行にも、透明なボヌダヌtransparentを最初から぀けおおく」のです。

    /* 未遞択時透明な5pxの壁を䜜っおおく */
    td { border-left: 5px solid transparent; }
    
    /* 遞択時色だけを倉える幅は倉わらないのでズレない */
    .is-selected td { border-left-color: #2cb696; }

    この地味な工倫が、ツヌルの「静かな」䜿い心地を支えおいたす。

    【第1䜍】CSV゚クスポヌト時の文字化けず゚スケヌプ凊理

    栄えある第1䜍は、最も実務的な機胜である「CSV出力」です。
    実は、日本語のCSV出力は鬌門です。単玔に出力するず、Excelで開いた時に盛倧に文字化けしたす。
    これを防ぐため、ファむルの先頭に BOMByte Order Mark ずいう「これはUTF-8ですよ」ずいう合図\uFEFFを付䞎したした。

    さらに、蚘事のタむトルや本文には、CSVの区切り文字である「カンマ,」や「改行」、あるいは「ダブルクォヌト"」が含たれおいる可胜性がありたす。これらをそのたた出力するず、列がズレおデヌタが壊れおしたいたす。

    // CSV甚゚スケヌプ関数: ダブルクォヌトを2぀重ね、党䜓を囲む
    const escapeCsv = (val) => `"${String(val).replace(/"/g, '""')}"`;

    この凊理を培底するこずで、どんなタむトルの蚘事であっおも、正確にExcelに取り蟌める匷固なCSV生成ロゞックを完成させたした。

    3. 【コピペで完成】拡匵機胜の䜜り方ず導入手順

    お埅たせしたした。それでは、実際にこのツヌルをあなたのブラりザに導入したしょう。
    プログラミングの知識は䞀切䞍芁です。WindowsでもMacでも、以䞋の手順通りに進めれば5分で完了したす。

    ステップ1必芁なファむル2぀を準備する

    たず、デスクトップなど分かりやすい堎所に、「note-article-search-master」か「note--search-extension」ずいう名前でフォルダを1぀新芏䜜成しおください。
    そのフォルダの䞭に、メモ垳などのテキスト゚ディタを䜿っお、以䞋の2぀のファむルを䜜成したす。

    ① 蚭定ファむルmanifest.json

    以䞋のコヌドをすべおコピヌし、manifest.json ずいう名前で保存しおください。

    {
      "manifest_version": 3,
      "name": "Note Article Master",
      "version": "1.0",
      "description": "note蚘事䞀芧を高床に管理・怜玢・゜ヌトするツヌル",
      "permissions": [],
      "content_scripts": [
        {
          "matches": ["https://note.com/notes"],
          "js": ["content_script.js"]
        }
      ]
    }

    ② プログラム本䜓content_script.js

    次に、以䞋のコヌドをすべおコピヌし、content_script.js ずいう名前で保存しおください。
    これがツヌルの頭脳ずなる郚分です。

    (async () => {
      let allArticles = [];
      let totalArticlesCount = 0;
      let filterStatus = 'all'; 
      let sortOrder = 'date';
      let isFullSearch = false;
      let lastClickedKey = null;
      let selectedIndex = -1; 
    
      // --- 1. CSS泚入 ---
      const style = document.createElement('style');
      style.textContent = `
        #master-launch-btn { position: fixed; top: 12px; right: 280px; z-index: 9999; padding: 8px 20px; background: #2cb696; color: white; border: none; border-radius: 20px; cursor: pointer; font-weight: bold; box-shadow: 0 4px 12px rgba(44,182,150,0.3); transition: 0.3s; }
        #master-launch-btn:hover { background: #249178; transform: translateY(-2px); }
        
        #master-panel { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #f4f7f6; z-index: 10000; display: none; flex-direction: column; font-family: sans-serif; outline: none; }
        
        .master-header { padding: 25px 25px 15px; background: white; border-bottom: 1px solid #e1e4e8; display: flex; flex-direction: column; align-items: center; gap: 15px; position: relative; }
        #progress-bar-container { position: absolute; bottom: 0; left: 0; width: 100%; height: 3px; background: #eee; }
        #progress-bar { width: 0%; height: 100%; background: #2cb696; transition: width 0.3s; }
        
        #master-close { position: absolute; left: 25px; top: 22px; cursor: pointer; background: none; border: none; font-size: 24px; color: #999; transition: 0.2s; }
        #master-close:hover { color: #333; }
    
        .search-row { display: flex; align-items: center; justify-content: center; gap: 15px; width: 100%; max-width: 950px; }
        .search-container { position: relative; flex-grow: 1; display: flex; align-items: center; }
        .search-box { width: 100%; padding: 14px 40px 14px 20px; border: 2px solid #e1e4e8; border-radius: 12px; font-size: 16px; outline: none; transition: 0.2s; }
        .search-box:focus { border-color: #2cb696; background: #f9fffb; }
        .search-clear { position: absolute; right: 12px; cursor: pointer; color: #ccc; font-size: 20px; display: none; background: none; border: none; }
        
        .hit-counter { font-size: 13px; font-weight: bold; color: #333; background: #f0f2f5; padding: 0 20px; height: 50px; display: flex; flex-direction: column; justify-content: center; align-items: center; border-radius: 12px; border: 1px solid #e1e4e8; min-width: 140px; white-space: nowrap; }
        .hit-main-num { font-size: 16px; color: #2cb696; }
        .hit-sub-info { font-size: 10px; color: #888; font-weight: normal; }
    
        /* CSV Export Button Style */
        #csv-export-btn {
          height: 50px; padding: 0 20px; border-radius: 12px; border: 1px solid #2cb696; background: white; color: #2cb696; font-weight: bold; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 6px; white-space: nowrap;
        }
        #csv-export-btn:hover { background: #eefcf9; }
        #csv-export-btn:active { transform: translateY(1px); }
        .icon-dl { font-size: 18px; }
    
        .chip-container { display: flex; gap: 10px; align-items: center; justify-content: center; width: 100%; }
        .chip { padding: 8px 16px; border-radius: 20px; border: 1.5px solid #dcdfe6; background: white; font-size: 12px; font-weight: bold; cursor: pointer; color: #606266; transition: 0.2s; white-space: nowrap; }
        .chip.active { background: #2cb696; color: white; border-color: #2cb696; box-shadow: 0 2px 8px rgba(44,182,150,0.25); }
        .chip-label { font-size: 11px; color: #999; margin-left: 10px; margin-right: 2px; }
    
        .master-main { flex-grow: 1; overflow-y: scroll; padding: 10px 40px 40px; scroll-behavior: auto; }
        .article-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
        
        .article-table td { 
          background: white; padding: 16px 20px; vertical-align: middle; transition: background 0.1s; border-left: 5px solid transparent; 
        }
        .article-row:hover td { background: #f9fffb; }
        .article-row.is-selected td { 
          background: #eefcf9 !important; box-shadow: inset 0 2px 0 #2cb696, inset 0 -2px 0 #2cb696; transition: none !important; 
        }
        .article-row.is-selected td:first-child { box-shadow: inset 5px 2px 0 -3px #2cb696, inset 0 -2px 0 #2cb696, inset 0 2px 0 #2cb696; }
        .article-row.is-selected td:last-child { box-shadow: inset -2px 2px 0 -0px #2cb696, inset 0 -2px 0 #2cb696, inset 0 2px 0 #2cb696; }
        .is-selected .col-no { color: #2cb696; font-weight: bold; }
        .last-active td { border-left-color: #2cb696 !important; }
    
        .col-no { width: 50px; text-align: center; color: #bbb; font-size: 11px; white-space: nowrap; }
        .col-status { width: 100px; text-align: center; white-space: nowrap; }
        .col-likes { width: 80px; text-align: center; font-size: 15px; white-space: nowrap; }
        .col-date { width: 120px; text-align: center; color: #666; font-size: 13px; white-space: nowrap; }
        .col-action { width: 220px; text-align: right; white-space: nowrap; }
        
        .likes-high { color: #f56c6c; font-weight: 900; }
        .likes-mid { color: #e6a23c; font-weight: bold; }
        
        .status-badge { display: inline-block; width: 55px; text-align: center; padding: 4px 0; border-radius: 6px; font-size: 11px; color: white; font-weight: bold; white-space: nowrap; }
        .badge-pub { background: #2cb696; }
        .badge-draft { background: #909399; }
        
        .thumb { width: 80px; height: 45px; border-radius: 6px; object-fit: cover; background: #eee; margin-right: 20px; flex-shrink: 0; border: 1px solid #f0f0f0; }
        .title-link { font-weight: bold; font-size: 16px; color: #2c3e50; text-decoration: none; display: inline-block; margin-bottom: 6px; line-height: 1.4; }
        .title-link:hover { color: #2cb696; text-decoration: underline; }
        
        .btn-small { text-decoration: none !important; font-weight: bold; padding: 10px 16px; border-radius: 8px; font-size: 12px; transition: 0.2s; display: inline-block; margin-left: 8px; cursor: pointer; border: 1.5px solid; background: white; white-space: nowrap; opacity: 0.4; }
        .article-row:hover .btn-small, .article-row.is-selected .btn-small { opacity: 1; }
        .edit-btn { color: #2cb696; border-color: #2cb696; }
        .copy-btn { color: #606266; border-color: #dcdfe6; }
        
        mark { background: #fff59d; color: #d84315; font-weight: bold; padding: 0 2px; }
        .month-divider { position: sticky; top: -10px; z-index: 5; padding: 25px 15px 12px; color: #2cb696; font-weight: bold; font-size: 18px; background: #f4f7f6; display: flex; align-items: center; gap: 15px; }
        .month-badge { font-size: 12px; background: white; border: 1.5px solid #2cb696; padding: 3px 10px; border-radius: 15px; font-weight: normal; }
        @keyframes flash-green { 0% { background: white; } 30% { background: #eefcf9; } 100% { background: white; } }
        .flash-success td { animation: flash-green 1s ease-out; }
        .empty-state { padding: 150px; text-align: center; color: #999; font-size: 18px; }
        .reset-link { color: #2cb696; cursor: pointer; text-decoration: underline; font-weight: bold; margin-left: 10px; }
      `;
      document.head.appendChild(style);
    
      // --- 2. UI構築 ---
      const launchBtn = document.createElement('button');
      launchBtn.id = 'master-launch-btn';
      launchBtn.textContent = '📊 Master Mode';
      document.body.appendChild(launchBtn);
    
      const panel = document.createElement('div');
      panel.id = 'master-panel';
      panel.tabIndex = 0; 
      panel.innerHTML = `
        <div class="master-header">
          <button id="master-close" title="Escで閉じる">✕</button>
          <div class="search-row">
            <div class="search-container">
              <input type="text" class="search-box" id="master-search" placeholder="タむトルのみ怜玢...">
              <button id="search-clear" class="search-clear">✕</button>
            </div>
            <div class="hit-counter" id="hit-count">読蟌䞭...</div>
            <button id="csv-export-btn" title="党デヌタをCSVで保存"><span class="icon-dl">📥</span> CSV出力</button>
          </div>
          <div class="chip-container" id="control-chips">
            <span class="chip-label">怜玢:</span>
            <button class="chip" data-id="mode-full">党文怜玢本文含</button>
            <span class="chip-label">衚瀺:</span>
            <button class="chip active" data-id="status-all">すべお</button>
            <button class="chip" data-id="status-published">公開䞭</button>
            <button class="chip" data-id="status-draft">䞋曞き</button>
            <span class="chip-label">䞊び替え:</span>
            <button class="chip active" data-id="sort-date">日付順</button>
            <button class="chip" data-id="sort-likes">人気順</button>
          </div>
          <div id="progress-bar-container"><div id="progress-bar"></div></div>
        </div>
        <div class="master-main" id="master-scroll-area">
          <table class="article-table">
            <tbody id="article-list-body"></tbody>
          </table>
        </div>
      `;
      document.body.appendChild(panel);
    
      // --- 3. デヌタ取埗 ---
      async function fetchAll() {
        if (allArticles.length > 0) return;
        let page = 1; let isLastPage = false;
        const pBar = document.getElementById('progress-bar');
        while (!isLastPage) {
          try {
            const res = await fetch(`https://note.com/api/v2/note_list/contents?page=${page}`).then(r => r.json());
            totalArticlesCount = res.data.totalCount;
            res.data.notes.forEach(note => {
              allArticles.push({
                key: note.key, status: note.status,
                title: note.name || (note.noteDraft ? note.noteDraft.name : "") || "タむトル未蚭定",
                peek: note.peekBody || "",
                fullContent: (note.status === 'draft' && note.noteDraft ? note.noteDraft.body : (note.peekBody || "")).replace(/<[^>]*>/g, ''),
                likes: note.likeCount || 0, date: note.displayDate, thumb: note.eyecatch || "",
                viewUrl: `https://note.com/${note.user.urlname}/n/${note.key}`,
                editUrl: `https://editor.note.com/notes/${note.key}/edit/`
              });
            });
            pBar.style.width = `${Math.round((allArticles.length / totalArticlesCount) * 100)}%`;
            updateGlobalCounter(allArticles.length, totalArticlesCount, allArticles);
            isLastPage = res.data.isLastPage; page++;
            if (!isLastPage) await new Promise(r => setTimeout(r, 600));
          } catch(e) { console.error("Fetch error:", e); break; }
        }
        setTimeout(()=> pBar.parentElement.style.display = 'none', 600);
        render();
      }
    
      function updateGlobalCounter(shownCount, totalCount, list) {
        const pub = list.filter(a => a.status === 'published').length;
        const hitCountEl = document.getElementById('hit-count');
        if (hitCountEl) {
          // 修正箇所display:flex columnに察応するため、行ごずにdivでラップする
          hitCountEl.innerHTML = `
            <div><span class="hit-main-num">${shownCount}</span> / ${totalCount} ä»¶</div>
            <div class="hit-sub-info">( 公開:${pub}  䞋曞:${list.length - pub} )</div>
          `;
        }
      }
    
      // --- 4. CSV゚クスポヌトロゞック ---
      function downloadCSV() {
        if (allArticles.length === 0) {
          alert("蚘事デヌタがありたせん。デヌタを読み蟌んでから実行しおください。");
          return;
        }
    
        const headers = ["ID", "Status", "Title", "Date", "Likes", "ViewURL", "EditURL", "BodySnippet"];
        // CSV甚゚スケヌプ関数: ダブルクォヌトを2぀に、党䜓をダブルクォヌトで囲む
        const escapeCsv = (val) => `"${String(val).replace(/"/g, '""')}"`;
    
        const csvRows = [
          headers.join(','), // ヘッダヌ行
          ...allArticles.map(a => {
            return [
              escapeCsv(a.key),
              escapeCsv(a.status),
              escapeCsv(a.title),
              escapeCsv(a.date),
              escapeCsv(a.likes),
              escapeCsv(a.viewUrl),
              escapeCsv(a.editUrl),
              escapeCsv(a.fullContent.substring(0, 500)) // 本文は長すぎるため500文字で切る
            ].join(',');
          })
        ];
    
        // BOM付䞎でExcel文字化け回避
        const csvString = '\uFEFF' + csvRows.join('\r\n');
        const blob = new Blob([csvString], { type: 'text/csv;charset=utf-8;' });
        const url = URL.createObjectURL(blob);
        
        const link = document.createElement('a');
        link.href = url;
        link.setAttribute('download', `note_articles_backup_${new Date().toISOString().slice(0,10)}.csv`);
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
      }
    
      // --- 5. 描画・怜玢・むンタラクション ---
      const tbody = document.getElementById('article-list-body');
      const searchInput = document.getElementById('master-search');
      const clearBtn = document.getElementById('search-clear');
      
      tbody.addEventListener('click', (e) => {
        const row = e.target.closest('.article-row');
        if (row) {
            const rows = Array.from(tbody.querySelectorAll('.article-row'));
            selectedIndex = rows.indexOf(row);
            syncSelection(false); 
        }
    
        if (e.target.classList.contains('copy-btn')) {
          const url = e.target.getAttribute('data-url');
          navigator.clipboard.writeText(url).then(() => {
            const row = e.target.closest('tr');
            row.classList.add('flash-success');
            const old = e.target.textContent; e.target.textContent = '完了';
            setTimeout(() => { e.target.textContent = old; row.classList.remove('flash-success'); }, 1000);
          });
        }
        if (e.target.classList.contains('edit-btn')) {
            lastClickedKey = e.target.closest('tr').getAttribute('data-key');
            render();
        }
      });
    
      function render() {
        const query = searchInput.value.trim();
        const queryLower = query.toLowerCase();
        const statusFilter = filterStatus;
        const sort = sortOrder;
    
        selectedIndex = -1; 
        searchInput.placeholder = isFullSearch ? "党文怜玢䞋曞きは党本文..." : "タむトルのみ怜玢...";
        clearBtn.style.display = query ? 'block' : 'none';
    
        let filtered = allArticles.filter(a => {
          const mStatus = (statusFilter === 'all' || a.status === statusFilter);
          const target = isFullSearch ? (a.title + a.fullContent).toLowerCase() : a.title.toLowerCase();
          return mStatus && target.includes(queryLower);
        });
    
        filtered.sort((a, b) => {
          if (sort === 'likes') return b.likes - a.likes;
          return new Date(b.date.replace(/\//g, '-')) - new Date(a.date.replace(/\//g, '-'));
        });
    
        updateGlobalCounter(filtered.length, totalArticlesCount, filtered);
    
        if (filtered.length === 0) {
          tbody.innerHTML = `<tr><td colspan="6" class="empty-state">䞀臎する蚘事がありたせん。<span class="reset-link" id="reset-all">リセット</span></td></tr>`;
          const resetEl = document.getElementById('reset-all');
          if (resetEl) resetEl.onclick = resetAllFilters;
          return;
        }
    
        const highlight = (text) => query ? text.replace(new RegExp(`(${query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`, 'gi'), '<mark>$1</mark>') : text;
        const getSnippet = (text) => {
          if (!query || !isFullSearch) return text.substring(0, 80);
          const idx = text.toLowerCase().indexOf(queryLower);
          if (idx === -1) return text.substring(0, 80);
          const start = Math.max(0, idx - 30);
          const end = Math.min(text.length, idx + 50);
          return (start > 0 ? '...' : '') + text.substring(start, end) + (end < text.length ? '...' : '');
        };
    
        let html = ''; let lastMonth = '';
        filtered.forEach((a, index) => {
          const currentMonth = a.date.substring(0, 7).replace('/', '幎') + '月';
          if (sort === 'date' && currentMonth !== lastMonth) {
            const mPub = filtered.filter(i => i.date.startsWith(a.date.substring(0, 7)) && i.status === 'published').length;
            html += `<tr><td colspan="6"><div class="month-divider">${currentMonth}<span class="month-badge">公開 ${mPub}  䞋曞 ${filtered.filter(i => i.date.startsWith(a.date.substring(0, 7)) && i.status === 'draft').length}</span></div></td></tr>`;
            lastMonth = currentMonth;
          }
          const rowGuideClass = a.key === lastClickedKey ? 'last-active' : '';
          const likeClass = a.likes >= 50 ? 'likes-high' : (a.likes >= 10 ? 'likes-mid' : '');
    
          html += `<tr class="article-row ${rowGuideClass}" data-key="${a.key}">
              <td class="col-no">${index + 1}</td>
              <td class="col-status"><span class="status-badge ${a.status === 'published' ? 'badge-pub' : 'badge-draft'}">${a.status === 'published' ? '公開' : '䞋曞'}</span></td>
              <td><div style="display:flex; align-items:center; overflow:hidden;">
                ${a.thumb ? `<img src="${a.thumb}" class="thumb">` : `<div class="thumb"></div>`}
                <div style="overflow:hidden;"><a href="${a.viewUrl}" target="_blank" class="title-link">${highlight(a.title)}</a>
                <div style="font-size:12px; color:#7f8c8d; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;">${highlight(getSnippet(a.fullContent))}</div></div>
              </div></td>
              <td class="col-likes ${likeClass}">${a.likes > 0 ? a.likes : '-'}</td>
              <td class="col-date">${a.date.split(' ')[0]}</td>
              <td class="col-action">
                <button class="btn-small copy-btn" data-url="${a.viewUrl}">URLコピヌ</button>
                <a href="${a.editUrl}" target="_blank" class="btn-small edit-btn">線集</a>
              </td>
            </tr>`;
        });
        tbody.innerHTML = html;
      }
    
      // --- 6. キヌボヌドナビゲヌション゚ンゞン ---
      function syncSelection(shouldScroll = true) {
        const rows = Array.from(tbody.querySelectorAll('.article-row'));
        if (rows.length === 0) return;
    
        if (selectedIndex < 0) selectedIndex = 0;
        if (selectedIndex >= rows.length) selectedIndex = rows.length - 1;
    
        rows.forEach(r => r.classList.remove('is-selected'));
        const target = rows[selectedIndex];
        target.classList.add('is-selected');
    
        if (shouldScroll) {
          target.scrollIntoView({ block: 'nearest', behavior: 'auto' });
        }
      }
    
      panel.addEventListener('keydown', (e) => {
        if (e.key === 'Escape') { 
            panel.style.display = 'none'; 
            document.body.style.overflow = ''; 
            return; 
        }
    
        const rows = tbody.querySelectorAll('.article-row');
        if (rows.length === 0) return;
    
        if (e.key === 'ArrowDown') {
          e.preventDefault();
          selectedIndex++;
          syncSelection();
        } else if (e.key === 'ArrowUp') {
          e.preventDefault();
          selectedIndex--;
          syncSelection();
        } else if (e.key === 'PageDown') {
          e.preventDefault();
          selectedIndex = Math.min(selectedIndex + 10, rows.length - 1);
          syncSelection();
        } else if (e.key === 'PageUp') {
          e.preventDefault();
          selectedIndex = Math.max(selectedIndex - 10, 0);
          syncSelection();
        } else if (e.key === 'Home') {
          e.preventDefault();
          selectedIndex = 0;
          syncSelection();
        } else if (e.key === 'End') {
          e.preventDefault();
          selectedIndex = rows.length - 1;
          syncSelection();
        } else if (e.key === 'Enter' && selectedIndex !== -1) {
            const link = rows[selectedIndex].querySelector('.title-link');
            if (link) link.click();
        }
      });
    
      // --- 7. むベントリスナヌ統合 ---
      function resetAllFilters() {
        searchInput.value = ''; filterStatus = 'all'; sortOrder = 'date'; isFullSearch = false;
        updateChipsUI(); render(); searchInput.focus();
      }
    
      function updateChipsUI() {
        document.querySelectorAll('.chip').forEach(c => {
          const id = c.getAttribute('data-id');
          c.classList.remove('active');
          if (id === 'mode-full' && isFullSearch) c.classList.add('active');
          if (id === `status-${filterStatus}`) c.classList.add('active');
          if (id === `sort-${sortOrder}`) c.classList.add('active');
        });
      }
    
      launchBtn.addEventListener('click', () => { panel.style.display = 'flex'; document.body.style.overflow = 'hidden'; searchInput.focus(); fetchAll(); });
      document.getElementById('master-close').addEventListener('click', () => { panel.style.display = 'none'; document.body.style.overflow = ''; });
      clearBtn.addEventListener('click', () => { searchInput.value = ''; render(); searchInput.focus(); });
      searchInput.addEventListener('input', render);
      document.getElementById('csv-export-btn').addEventListener('click', downloadCSV); 
      
      document.getElementById('control-chips').addEventListener('click', (e) => {
        const chip = e.target.closest('.chip');
        if (!chip) return;
        const id = chip.getAttribute('data-id');
        if (id === 'mode-full') isFullSearch = !isFullSearch;
        if (id.startsWith('status-')) filterStatus = id.replace('status-', '');
        if (id.startsWith('sort-')) sortOrder = id.replace('sort-', '');
        updateChipsUI(); render();
      });
    })();

    ステップ2ブラりザに導入する

    フォルダに2぀のファむルが入っおいるこずを確認したら、ブラりザに読み蟌たせたす。Google Chrome、たたはEdgeでの手順です。

    1. 拡匵機胜の管理画面を開く

      • Chromeの堎合アドレスバヌに chrome://extensions ず入力しおEnter。

      • Edgeの堎合edge://extensions ず入力しおEnter。

    2. デベロッパヌモヌドをONにする

      • 画面右䞊の「デベロッパヌモヌド」ずいうスむッチをONにしたす。

    3. フォルダを読み蟌む

      • 「パッケヌゞ化されおいない拡匵機胜を読み蟌む」ずいうボタンをクリックしたす。

      • 先ほど䜜成した「note-tool」フォルダを遞択しお、「開く」を抌したす。

    䞍芁になったらアンむンストヌル

    このツヌルが䞍芁になった堎合、䞊蚘ず同じ拡匵機胜の管理画面から「削陀」を抌すだけで、PC内にファむルやデヌタは䞀切残りたせん。安心しお詊しおみおください。

    これでむンストヌルは完了です
    さっそく、以䞋の手順で動䜜確認をしおみおください。

    1. noteのトップペヌゞhttps://note.comにアクセスしたす。

    2. 右䞊の自分のアむコンをクリックし、メニュヌから 「蚘事」たたは「自分の蚘事」を遞んで管理画面/notesぞ移動したす。

    3. ここで必ず、ブラりザの「再読み蟌みリロヌド」ボタンを䞀床抌しおください。F5キヌたたはURLバヌ暪の曎新ボタン

    4. 拡匵機胜はペヌゞが読み蟌たれた瞬間に準備を始めたすが、初回だけはリロヌドしないず反映されないこずがありたす。

    5. 画面右䞊に、緑色の「📊 Master Mode」ずいうボタンが出珟しおいれば成功です。

    画像
    「Master Mode」ボタン

    図解で解説する䜿い方

    画像
    アむコンをクリック
    画像
    「自分の蚘事」をクリック
    画像
    「F5」で曎新
    画像
    「Master Mode」が出珟
    画像
    「Master Mode」をクリック
    画像
    デヌタ出力埅ち....... 秒
    画像
    デヌタ抜出完了
    画像
    怜玢ワヌドを入力
    画像
    打った瞬間に絞り蟌たれる。思考を止めない怜玢䜓隓。
    200蚘事の䞭から䞀瞬で発掘。これが「Master Mode」。

    4. ご利甚いただく前の、正盎な話

    このツヌルを安心しお、そしお長く䜿っおいただくために、いく぀か重芁なこずをお䌝えしたす。

    ① サヌバヌぞの配慮ず「埅ち時間」に぀いお

    初めおボタンを抌したずき、党蚘事の読み蟌みに時間がかかる堎合がありたす。
    目安ずしお、蚘事数が200件ほどある堎合、読み蟌み完了たでに玄30秒ほどお埅ちいただくこずになりたす。

    「少し長いな」ず感じるかもしれたせんが、これはnoteのサヌバヌに負荷をかけないよう、人間がペヌゞをめくる速床に合わせおゆっくりデヌタを取埗しおいるためです。
    プログレスバヌが動いおいる間は、焊らずコヌヒヌでも飲みながらお埅ちください。䞀床読み蟌めば、画面をリロヌドするたで再読み蟌みは䞍芁です。

    ② プラむバシヌずセキュリティ

    このツヌルは、取埗した蚘事デヌタをあなたのブラりザメモリの䞭だけで凊理したす。
    倖郚のサヌバヌにデヌタを送信したり、誰かに共有したりする機胜は䞀切ありたせん。
    たた、パスワヌドや決枈情報などにアクセスする暩限も持っおいたせんので、安心しおご利甚ください。

    ③ 非公匏ツヌルであるこず自己責任

    この拡匵機胜は、私個人が趣味で開発したものであり、note公匏ずは䞀切関係ありたせん。
    noteの仕様倉曎により、将来的に突然動かなくなる可胜性もありたす。
    たた、䞇が䞀このツヌルの䜿甚によっお䜕らかの問題が発生しおも、責任を負うこずはできたせん。あくたで「自己責任」の範囲で、䟿利な実隓ツヌルずしおお楜しみください。

    おわりに

    画像
    たずめ

    ツヌルはあくたで「手段」です。
    この拡匵機胜の目的は、あなたの蚘事をきれいに䞊べるこずではなく、「探す時間」を枛らし、あなたが「新しい蚘事を曞く時間」を増やすこずにありたす。

    もしこのツヌルが、あなたの創䜜掻動を少しでも快適にし、埋もれおいた䞋曞きから名䜜が生たれるきっかけになれば、開発者ずしおこれ以䞊の喜びはありたせん。

    あなたのnoteラむフが、より豊かで、静かなものになりたすように。

    音声解説

    #note #プログラミング #゚ンゞニア #Chrome拡匵機胜 #JavaScript #業務効率化 #コピペで䜿える #noteの曞き方 #ラむフハック #Web開発 #生産性向䞊 #自䜜ツヌル #バックアップ #資産圢成 #駆け出し゚ンゞニアず繋がりたい #note曞き初め #぀くっおみた

    CSV出力機胜なしの初期バヌゞョン自分甚の備忘録

     
     
    note毎日投皿を玄1幎継続䞭AIを掻甚しお川柳や音楜コンテストで受賞できた私の詊行錯誀から、いたすぐ詊せる【実践的なAI掻甚術】を発信しおいたす。AIの力で、あなたの創䜜や日垞を少し䟿利に。泥臭い実践の蚘録が、あなたのヒントになるかもしれたせん。