Movatterモバイル変換


[0]ホーム

URL:


はてラボはてな匿名ダイアリー
ようこそ ゲスト さんログインユーザー登録
< anond:20220815201719 |[今日のワイの餌] >

2022-08-15

Webはてブミュー機能作った

勝手に tampermonkey とかに突っ込んで使ってヨロ

スクリプト保守とかするつもりないから、保守とかするつもりのあるパワーの溢れた人が

これ参考とかにしてもっとかっちょよくしたのを greasy fork あたりに公開してくれ

そしたら俺もそれ使う

使い方:

ブラウザの開発環境を開いて、開発コンソールを開く

localStorage.hatebu_ng_word_list に非表示トリガーになる文字列を|区切り登録する。

localStorage.hatebu_ng_word_list = "池田信夫|フェミ|弱者男性|やまもといちろう"

実際のコード

大なり小なり(&gt;)が実体参照で表示されるのはよくわからん。使う人で適宜コードを直してくれ。

// ==UserScript==// @nameはてブの一覧NG記事非表示// @namespacehttp://tampermonkey.net/// @version      0.1// @descriptiontry totakeoverthe world!// @author       masuda// @matchhttps://b.hatena.ne.jp/*// @iconhttps://www.google.com/s2/favicons?sz=64&domain=hatena.ne.jp// @grant        none// ==/UserScript==(function() {'use strict';if (!localStorage.hatebu_ng_word_list) {return;}console.log("はてブの一覧NG記事非表示", localStorage.hatebu_ng_word_list);/* * 例: * localStorage.hatebu_ng_word_list = * "池田信夫|フェミ|弱者男性|やまもといちろう|togetter.com";*/let words = localStorage.hatebu_ng_word_list.split('|').map(w =&gt; newRegExp(w));function entryDelete(els) {els.forEach(el =&gt; {let hit =false;words.forEach(w =&gt; {hit = hit|| w.test(el.textContent);});if (hit) {el.remove();}});}// entrylist-header-main li 1つ目のアイテムentryDelete(document.querySelectorAll('.entrylist-header-main&gt; li'));// 2つ目以降の liアイテムentryDelete(document.querySelectorAll('.entrylist-item&gt; li'));})();

文字正規表現として評価されて、ヒットした記事項目をページから削除する(DOMから要素を削除する)。

際限なくNG登録できるけど、沢山非表示するとつまらない一覧になる

Permalink |記事への反応(0) | 20:19

このエントリーをはてなブックマークに追加ツイートシェア

記事への反応 -

記事への反応(ブックマークコメント)

全てのコメントを見る

人気エントリ

注目エントリ

ログインユーザー登録
ようこそ ゲスト さん
Copyright (C) 2001-2025 hatena. All Rights Reserved.

[8]ページ先頭

©2009-2025 Movatter.jp