Skip to content

Instantly share code, notes, and snippets.

@noromanba
Last active March 4, 2016 21:45
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/e2fcfb01b2be8a12be79 to your computer and use it in GitHub Desktop.
Save noromanba/e2fcfb01b2be8a12be79 to your computer and use it in GitHub Desktop.
hidden spam on Hatena::Let w/ Pager Extension for UserScript
// ==UserScript==
// @name Hatena::Let spam filter
// @namespace http://noromanba.flavors.me
// @description hidden spam on Hatena::Let w/ Pager Extension for UserScript
// @include http://let.hatelabo.jp/*
// @grant none
// @noframes
// @run-at document-end
// @version 2016.3.4.1
// @homepage https://gist.github.com/noromanba/e2fcfb01b2be8a12be79
// @downloadURL https://gist.github.com/noromanba/e2fcfb01b2be8a12be79/raw/hatenalet-spamfilter.user.js
// @contributor a-kuma3 http://let.hatelabo.jp/a-kuma3/let/hJme3Kz9g6Zc (Fork of)
// @license MIT License http://nrm.mit-license.org/2016
// @author noromanba http://noromanba.flavors.me
// @icon https://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/ISO_7010_M017.svg/32px-ISO_7010_M017.svg.png
// @icon64 https://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/ISO_7010_M017.svg/64px-ISO_7010_M017.svg.png
// ==/UserScript==
// Icon (PD by BAuA http://www.baua.de /ISO 7010)
// https://commons.wikimedia.org/wiki/File%3AISO_7010_M017.svg
// Bookmarklet
// http://let.hatelabo.jp/noromanba/let/hLHUwYu31Z5O
// Devel
// https://gist.github.com/noromanba/e2fcfb01b2be8a12be79
// feedback to Hatena c.f.
// http://www.hatena.ne.jp/faq/q/let
// http://let.hatelabo.jp/noromanba/let/hLHW16C50Zpx
// Hatena Question spam-filter
// http://let.hatelabo.jp/noromanba/let/hLHWrvnr8Mlx
// spammer report c.f.
// http://ptech.g.hatena.ne.jp/noromanba/20141126/1417027101
// http://ptech.g.hatena.ne.jp/noromanba/20150105/1420463835
(() => {
// valid js url patterns; String, url(), RegExp c.f.
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/RegExp
// https://en.wikipedia.org/wiki/Regular_expression
// http://yut.hatenablog.com/entry/20110305/1299318337
// TBD \cX \xhh \uhhhh
const invalidURL = /(?:^|[^"'\s\/^.\\dwstrnvfb0\[\]^|$()?:*{},=!])(?:https?:)+/i;
const wipeout = (ctx) => {
Array.from(ctx.querySelectorAll('.codelist'), (list) => {
const packed = list.querySelector('.packed-source');
const title = (list.querySelector('.title .code-path') || {});
if (!packed || // XXX violate @require only src
title.textContent === 'no title' ||
invalidURL.test(packed.textContent)) {
//*
list.style.display = 'none';
/*/
list.style.backgroundColor = 'red';
//*/
}
});
};
wipeout(document.body);
// for Pager Extensions
new MutationObserver((records) => {
records.forEach((record) => {
wipeout(record.target);
});
}).observe(document.body, { childList: true, subtree: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment