Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@noromanba
Last active February 3, 2016 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noromanba/0606d92a17c3c17d5902 to your computer and use it in GitHub Desktop.
Save noromanba/0606d92a17c3c17d5902 to your computer and use it in GitHub Desktop.
hidden spam topics on Hatena Space for UserScript
// ==UserScript==
// @name Hatena Space ham topics
// @namespace http://noromanba.flavors.me
// @description hidden spam topics on Hatena Space for UserScript
// @include http://space.hatena.ne.jp/*
// @grant none
// @noframes
// @run-at document-end
// @version 2016.2.3.0
// @homepage https://gist.github.com/noromanba/0606d92a17c3c17d5902
// @downloadURL https://gist.github.com/noromanba/0606d92a17c3c17d5902/raw/hatenaspace-ham-topics.user.js
// @contributor a-kuma3 http://let.hatelabo.jp/a-kuma3/let/hLHUy6LimuEc
// @license MIT License http://opensource.org/licenses/MIT
// @author noromanba http://noromanba.flavors.me
// @icon https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Japanese_Weather_symbol_%28Dust_storm_or_Sand_storm%29.svg/32px-Japanese_Weather_symbol_%28Dust_storm_or_Sand_storm%29.svg.png
// @icon64 https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Japanese_Weather_symbol_%28Dust_storm_or_Sand_storm%29.svg/64px-Japanese_Weather_symbol_%28Dust_storm_or_Sand_storm%29.svg.png
// ==/UserScript==
// Icon (PD by Monaneko)
// https://commons.wikimedia.org/wiki/File%3AJapanese_Weather_symbol_%28Dust_storm_or_Sand_storm%29.svg
// Devel
// https://gist.github.com/noromanba/0606d92a17c3c17d5902
// Bookmarklet
// http://let.hatelabo.jp/noromanba/let/hLHUz7vPqd5w
// via
// http://a-kuma3.hatenablog.com/entry/hatena_space_backup
// e.g.
// http://space.hatena.ne.jp/~/14290001378108575017
(() => {
const spamTitle = /^(?:https?:\/\/\S+|[A-z0-9 =+<>*$'.!"\[\]():\^&#\-'{}_~\/|]+$)/;
// support expand/close topics
Array.from(document.body.querySelectorAll([
'.board-list [data-topic-id]'
// topic list AWFUL markup on space top;
// <li "> or <li class="hide"> WTF
])).concat(Array.from(document.body.querySelectorAll([
'.space-topic-data'
]), count => count.parentNode)).forEach(topic => {
// reset visibility
topic.classList.remove('hide');
const title = (topic.querySelector('a[title]') || {}).title;
if (!title || spamTitle.test(title)) {
topic.style.display = 'none';
return;
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment