Filter Extra Flags

Filtering specific regional flags for int

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name        Filter Extra Flags
// @namespace   http://vexxed.github.io/
// @description Filtering specific regional flags for int
// @include     http*://boards.4chan.org/int/*
// @include     http*://boards.4chan.org/pol/*
// @include     http*://boards.4chan.org/bant/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @version     0.01
// @grant       none
// @run-at document-end
// ==/UserScript==

//TODO: Make a native 4chan version, only filter and check new posts when updating
$(window).load(function(){
	dBug("Document is ready!");
	var filteredRegions = ["California", "Iroquois"]; //replace these with any you like
	var regions = [];

	document.addEventListener('ThreadUpdate', function (e) {
		getFlags();
	}, false);

	function matchRegions(filteredFlags, flags){
		for (var i = flags.length - 1; i >= 0; i--) {
			for (var j = filteredFlags.length - 1; j >= 0; j--) {
				if (flags[i].children[0].title == filteredFlags[j]){
					dBug("filtered: " + filteredFlags[j]);
					if ( isVisible(flags[i].parentNode.parentNode.parentNode.previousSibling.children[0]))
						flags[i].parentNode.parentNode.parentNode.previousSibling.children[0].click();
				}
			}
		}
	};

	function isVisible(e) {
    	return !!( e.offsetWidth || e.offsetHeight || e.getClientRects().length );
	}

	function getFlags(){
		regions = document.getElementsByClassName("extraFlag");
		matchRegions(filteredRegions, regions);
	};

	function dBug(data){
		//console.log(data);
	};

	setTimeout(function() {
		getFlags();
    }, 0);
});