// ==UserScript==
// @name 学園祭カレンダー絞り込み
// @description s:絞り込み (とどラン)a:相関が弱いものを消す
// @version 0.3.11
// @run-at document-idle
// @match *://*.5ch.net/*
// @match *://auctions.yahoo.co.jp/category/list/*
// @match *://auctions.yahoo.co.jp/search/search*
// @match *://auctions.yahoo.co.jp/seller/*
// @match *://auctions.yahoo.co.jp/jp/show/*
// @match *://choku-buy.com/*
// @match *://fmfm.jp/*
// @match *://labo.tv/2chnews/*
// @match *://omocoro.jp/*
// @match *://oowata.com/*
// @match *://owata-net.com/*
// @match *://workman.jp/shop/*
// @match *://todo-ran.com/t/soukan/*
// @match *://todo-ran.com/t/kiji/*
// @match *://www.gakkou.net/daigaku/gakuensai/*
// @match *://www.nicochart.jp/user/*
// @match *://www.nicochart.jp/search/*
// @match *://www.nicochart.jp/name/*
// @match *://www.nicochart.jp/tag/*
// @match *://www.nicovideo.jp/ranking
// @match *://www.nicovideo.jp/search/*
// @match *://www.nicovideo.jp/tag/*
// @match *://www.nicovideo.jp/user/*
// @match *://www.nicovideo.jp/series/*
// @match *://www.nicovideo.jp/my/mylist*
// @match *://www.nicovideo.jp/my/watchlater*
// @match *://www.suruga-ya.jp/pcmypage/action_favorite_list/detail/*
// @match *://www.youtube.com/*
// @match *://www.youtube.com/channel/*
// @match *://www.youtube.com/user/*
// @match *://www.youtube.com/playlist?list=*
// @match *://gigazine.net/*
// @match *://gigazine.net/news/C*
// @match *://www.ebay.com/sch/*
// @match *://www.lifehacker.jp/*
// @match *://www.gizmodo.jp/*
// @match *://ja.aliexpress.com/*
// @match *://www.nicovideo.me/*
// @match *://kuzure.but.jp/*
// @match *://*.2chan.net/*
// @match *://*.userbenchmark.com/*
// @match *://commons.nicovideo.jp/*
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM.setClipboard
// @require https://code.jquery.com/jquery-3.4.1.min.js
// @namespace https://greasyfork.org/users/181558
// ==/UserScript==
(function() {
const historyLen = 50;
const EXPERT = 0;
const HIGHLIGHT_KEY = "Disable"; // "h";
const LogMatch = 0;
const WAIT = performance.now();
if (window !== parent) return;
const SITEINFO = [ // 上が優先
{
url: '//commons.nicovideo.jp/',
filterItem: '//div/ul/li[@class="item2"]',
filterPlace: '//div[@class="inner"]/div[@data-is-owner=""]/div/p',
delayAutoWeighting: 1,
}, {
url: '//.+.userbenchmark.com/',
filterPlace: '//p[@class="medp two-cols fl-dc"]',
filterItem: '//span[@class="semi-strongs lighterblacktexts"]/../../../..',
filterSampleWord: '',
}, {
url: '//.*.5ch.net/.*?/subback.html',
filterPlace: '//body/div[@class="block"]/small/a[3]|//div[@class="floated"]/small/a[3]/b|/HTML/BODY/DIV[1]/SMALL[1]/A[3]/B[1]|//html/body/div[@class="floated"]/small/a[3]/b',
filterItem: '//small[@id="trad"]/a|//div[@class="block"]/small/a|//div[@class="floated"]/small/a',
filterSampleWord: '',
}, {
url: /\/\/.*\.5ch\.net\/\w*\/$/,
filterItem: '//div[@id="thread-list-box"]/table[@id="thread-list"]/tbody/tr/td/a/../..',
filterPlace: '//div[@id="thread-list-top-bar"]', // //div[@id="thread-list-box"]/div[@id="thread-list-top-bar"]',
delay: 1000,
}, {
url: '//.*\.5ch\.net/',
filterPlace: '//h1[@class="title"]',
filterItem: '//div[@class="post"]',
important: true,
filterFunc: function() {
$('div.post:hidden').next("br").css("display", "none");
$('div.post:visible').next("br:hidden").css("display", "block");
}, //余計な改行を詰める
//highlightKey:"h",
filterSampleWord: 'ttp',
}, {
url: '//.*?.2chan.net/',
filterPlace: '/HTML/BODY/HR[2]',
filterItem: '//tr/td[@class="rtd"]/../../..',
filterSampleWord: 'B\\)|そうだねx',
}, {
url: '//kuzure.but.jp/',
filterPlace: '//div[@id="head"]/hr',
filterItem: '//tr/td[@class="rtd"]/../../..',
filterSampleWord: 'B\\)|そうだねx',
}, {
url: '//www.nicovideo.jp/my/watchlater|//www.nicovideo.jp/my/mylist/',
filterPlace: '//section[@class="WatchLaterContainer"]/header|//div/header[@class="MylistHeader"]',
//filterItem: '//span[@class="VideoMediaObject-bodyTitle"]/../../../../..',
filterItem: '//div[@class="CheckboxVideoMediaObject MylistItem MylistItemList-item"]|//div[@class="CheckboxVideoMediaObject WatchLaterListItem WatchLaterList-item"]',
delayAutoWeighting: 5,
observeURL: 6, // よくわからないけど要リロード
}, {
url: '//www.nicovideo.jp/user/.+/mylist/', // 様子見
filterPlace: '//h1[@class="MylistHeader-name"]',
filterItem: '//div[@class="VideoMediaObject MylistItem MylistItemList-item"]',
// delayAutoWeighting:5,
observeURL: 6, // よくわからないけど要リロード
delay: 3000,
}, {
url: '//www.nicovideo.me/',
filterPlace: '//div[@class="center mvm"]',
filterItem: '//ul[@id="data-videos"]/li',
}, {
url: "//www.gakkou.net/daigaku/gakuensai/",
filterPlace: "H2.GESTitle",
mapPlace: "h3.ListTtlN",
filterItem: "ol[class^='articleListN']>li",
filterSampleWord: "東京",
}, {
url: '//ja.aliexpress.com/',
filterItem: '//li[@class="list-item"]',
filterPlace: '//div[@class="next-breadcrumb"]',
}, {
url: "//todo-ran.com/t/soukan/|//todo-ran.com/t/kiji/",
filterPlace: "div.kiji_ktext",
filterItem: '//table[@id="t_soukan_r"]/tbody/tr/td[1]/a/../..|//table[@class="kenbetsuranking" and @id="t_soukan"]/tbody/tr/td/a/../..',
filterSampleWord: "消費量",
}, {
url: "//fmfm.jp/",
filterPlace: '#calendarTitleDate',
filterItem: 'div.eventListbox',
filterSampleWord: "東京",
}, {
url: "//www.nicovideo.jp/ranking",
filterPlace: "div.BaseLayout-block ul",
filterItem: '//div[@class="Card-title"]/..',
filterSampleWord: "!ゆっくり 解説|講座",
}, {
url: "//www.youtube.com/results",
filterPlace: '//div[@id="filter-menu"]',
filterItem: '//div[@id="dismissable"]|//ytd-playlist-renderer|//ytd-channel-renderer|//ytd-movie-renderer|//ytd-horizontal-card-list-renderer',
observeURL: 3,
}, {
url: "//www.youtube.com/channel/.*/search|//www.youtube.com/user/.*/search",
filterPlace: '//input[@class="style-scope paper-input"]',
filterItem: '//*[@class="style-scope ytd-section-list-renderer"]',
observeURL: 3,
filterSampleWord: "!\\d\\s年前|\\d\\sか月前|\\d\\s週間前",
}, {
url: "//www.youtube.com/channel/|//www.youtube.com/c/|//www.youtube.com/user/",
filterPlace: "div#primary-items",
filterItem: "div.style-scope ytd-grid-video-renderer,ytd-grid-playlist-renderer",
observeURL: 3,
filterSampleWord: "!\\d\\s年前|\\d\\sか月前|\\d\\s週間前",
}, {
url: "//www.youtube.com/playlist\?",
filterPlace: '//div[@id="items"]/ytd-playlist-sidebar-secondary-info-renderer',
filterItem: '//*[@class="style-scope ytd-playlist-video-list-renderer"]',
observeURL: 3,
filterSampleWord: "!\\d\\s年前|\\d\\sか月前|\\d\\s週間前",
}, {
url: "//www.youtube.com/$",
filterPlace: '//div[@id="alerts"]', //'//div[@id="sections"]/ytd-guide-section-renderer[2]',////'//span[@id="title" and text()="あなたへのおすすめ"]', //'span#title:contains("あなたへのおすすめ"):visible',
filterItem: '//div[@id="dismissable"]/../../..',
observeURL: 3,
filterSampleWord: "!\\d\\s年前|\\d\\sか月前|\\d\\s週間前",
}, {
url: "//www.youtube.com/",
filterPlace: '',
filterItem: '',
observeURL: 3,
}, {
url: "//omocoro.jp/",
filterPlace: '//div[@class="tag-inner"]/h2[@class="waku-text"]|//div[@class="category-inner"]/h2[@class="waku-text"]|//div[@class="new-entries"]/div/h2[@class="title waku-text"]|//div[@class="writer-inner"]/h2[@class="waku-text"]',
filterItem: "div.box",
}, {
url: "//workman.jp/shop/goods/search|//workman.jp/shop/brand/|//workman.jp/shop/c",
filterPlace: '//header/div[@class="container"]|//div[@class="block-goods-list--pager-top block-goods-list--pager pager"]',
filterItem: '//div[@class="_item"]|//div[@class="_wrap"]/..|//dl[@class="block-thumbnail-t--goods js-enhanced-ecommerce-item"]',
filterSampleWord: "ストレッチ|STRETCH",
observeURL: 1,
delay: 1500,
}, {
url: "//www.nicovideo.jp/user/", // 2020年07月27日リニューアル用 様子見
filterPlace: '//header[@class="VideoContainer-header"]',
filterItem: '//div[@class="VideoMediaObject-body"]/span/../../../..',
delay: 1000,
/*}, {
url: "//www.nicovideo.jp/user/",
filterPlace: "div.outer.VideoListHeadMenuContainer",
filterItem: '//div[@class="outer VideoItem"]',
*/
}, {
url: '//www.nicovideo.jp/tag/',
filterPlace: '//div[@class="column main"]/div[2]/div[@class="toolbar"]',
filterItem: 'li.item.nrn-thumb-info-done',
}, {
url: '//www.nicovideo.jp/search/',
filterPlace: '//div[@id="nrn-config-bar"]',
filterItem: '//li[@data-nicoad-video=""]',
}, {
url: '//choku-buy.com/',
mapPlace: '//p[@class="address"]'
}, {
url: '//auctions.yahoo.co.jp/search/search',
filterPlace: '//div[@class="Options"]',
filterItem: '//li[@class="Product"]',
filterSampleWord: '!認証制限.:あり \\d時間|\\d分',
}, {
url: '//auctions.yahoo.co.jp/seller/',
filterPlace: '//div[@class="bd"]/..',
filterItem: '//td[@class="i"]/..',
filterSampleWord: '!認証制限.:あり \\d時間|\\d分',
}, {
url: '//auctions.yahoo.co.jp/category/list/',
filterPlace: '//div[@class="Options"]',
filterItem: '//li[@class="Product"]',
filterSampleWord: '!認証制限.:あり \\d時間|\\d分',
}, {
url: '//www.nicochart.jp/user/|//www.nicochart.jp/search/|//www.nicochart.jp/name/|//www.nicochart.jp/tag/',
filterPlace: '//div[@id="result"]/ul[1]',
filterItem: '//ul[@class="video-list"]/li/ul/..',
}, {
url: '//labo.tv/2chnews/',
filterPlace: '//html/body/center/table/tbody/tr/td[@align="left"]/h2',
filterItem: '//html/body/center/table/tbody/tr/td[@valign="top"]/div/ul/li',
}, {
url: '//owata-net.com',
filterPlace: '//div/div[@class="clearfix"]',
filterItem: '//div[@class="feed clearfix"]|//div[@class="feed-list"]/div',
}, {
url: '//oowata.com',
filterPlace: '//div[4]/ul[@id="globalNavi"]',
filterItem: '//td[contains(@class,"t")]/..|//ul/li[@class="t"]',
}, {
url: '//www.suruga-ya.jp/pcmypage/action_favorite_list/detail/',
filterPlace: '//form[contains(@class,"favorite-form") and @method="post"]',
filterItem: '//td[@class="gnavBox"]',
filterSampleWord: '税込',
}, {
url: '//auctions.yahoo.co.jp/jp/show/rating',
filterPlace: '//b[text()="評価コメントの一覧"]',
filterItem: '//tr[2]/td[@colspan="3"]/small/a/../../../../..',
}, {
url: 'gigazine.net/|gigazine.net/news/C',
filterPlace: '//header[@id="header"]',
filterItem: '//div[@class="content"]/section|//div[@id="search_results"]/section',
filterSampleWord: '!試食|ヘッドライン|取材',
}, {
url: '//www.ebay.com/sch/',
filterPlace: '//div/div/div[@class="clearfix srp-controls__row-2"]',
filterItem: '//li[@class="s-item "]/div/..',
}, {
url: '//www.lifehacker.jp/',
// filterPlace: 'h2.lh-block-title:contains("記事"):visible,div>div>h2:contains("の検索結果"):visible',
filterPlace: '//h2[@class="lh-block-title" and contains(text(),"記事")]|//div/div[1]/h2[contains(text(),"の検索結果")]',
filterItem: '//div[@class="lh-summary"]|//div/a[@class="lh-summary"]',
filterSampleWord: '方法',
}, {
url: '//www.nicovideo.jp/series/',
filterPlace: '//div[@class="SeriesDetailContainer-media"]',
filterItem: '//div[@class="SeriesVideoListContainer"]/div',
}, {
url: '//www.gizmodo.jp/',
filterPlace: '//div[@class="h-body-header"]/div',
filterItem: '//article[@class="p-timeline-cardPost"]|//ul[@class="p-slider1-cardList swiper-wrapper"]/li|//div/div[@class="p-cardHead"]/article|//section[@class="s-Ranking_ListItemPost"]|//article[@class="s-body-cardList3CardPost"]|//article[@class="p-post-reviewList-CardPost"]|//article[@class="p-archive-cardPost"]',
filterSampleWord: '',
}, {
url: '//.*',
filterPlace: '//div[1]',
filterItem: '//div|//td|//li',
filterSampleWord: '',
mapPlace: '',
important: false,
filterFunc: null,
}, {
url: '',
filterPlace: '',
filterItem: '',
filterSampleWord: '',
mapPlace: '',
important: false,
filterFunc: null,
}, {
url: '',
filterPlace: '',
filterItem: '',
filterSampleWord: '',
mapPlace: '',
important: false,
filterFunc: null,
}, {
url: '', //対応URLにmatchする正規表現
filterPlace: '', //絞り込みフォームを設置する場所 XPathかjQueryセレクタ(省略可)
filterItem: '', //絞り込みフォームで絞り込む要素 XPathかjQueryセレクタ(省略可)
filterSampleWord: '', //絞り込みフォームの検索ワード例(省略可)
mapPlace: '', //地図検索を設置したい住所の書いてある要素 XPathかjQueryセレクタ(省略可)
important: false, //!importantを付けないと非表示にできないサイトでtrueを指定(省略可)
filterFunc: null, //絞り込み実行時に行わせたい追加処理(省略可)
observeURL: 0, //1以上ならURLが変化したら再処理を数値の回数繰り返す(省略可)
delay: 0, //ページ開始時から処理開始までの遅延ミリ秒 (省略可)
delayAutoWeighting: 0, // 0以外ならページ開始時から処理開始までの遅延量 ブラウザと回線の重さから算出した基本値にこの数をかける(省略可)
}
];
var shiboDNIevent;
var shiboTimer = null;
var searRE;
// match文を生成 *不完全
if (LogMatch) {
let matchlist = ""
for (let s of SITEINFO.slice().sort(function(a, b) { return a.url > b.url ? 1 : -1 })) {
if (s.url != "")
for (let s2 of s.url.split("|")) {
matchlist += "// @match *:" + s2.replace(/\.\*/gm, "*").replace(/^\./, "//*.") + "*\n";
}
}
alert(matchlist);
}
// thissiteを決定
var thissite = null;
thissite = decideThissite();
if (thissite === null) return;
function decideThissite() {
thissite = null;
for (var i = 0; i < SITEINFO.length; i++) {
if (SITEINFO[i].url == "") break;
if (location.href.match(SITEINFO[i].url)) {
if (SITEINFO[i].url === "//.*" && EXPERT == 0) return null;
thissite = i;
break;
}
}
return thissite;
}
if (LogMatch) console.log(SITEINFO[thissite]);
//URL遷移を監視
var href = location.href;
var observer = new MutationObserver(function(mutations) {
if (href !== location.href) {
href = location.href;
$(document).off('keydown.shibo');
$(".shibo").remove();
if (shiboDNIevent && SITEINFO[thissite].observeURL) setTimeout(() => { run("url"); }, 1500)
for (let i = 0; i < (SITEINFO[thissite].observeURL || 1) + 0; i++) setTimeout(run, 1000 + i * 1000);
}
});
observer.observe(document, { childList: true, subtree: true });
if (SITEINFO[thissite].delayAutoWeighting) SITEINFO[thissite].delay = WAIT * SITEINFO[thissite].delayAutoWeighting;
setTimeout(() => { run() }, SITEINFO[thissite].delay || 0);
return;
function run(mode) {
$(".shibo").remove();
$(document).off('keydown.shibo');
if (shiboDNIevent || mode === "url") {
document.body.removeEventListener('DOMNodeInserted', shiboDNIevent);
shiboDNIevent = null;
shibo("");
}
thissite = decideThissite();
if (thissite === null) return;
const tips = "Tips:\n「ABCやDEFを含まず、GHIかJKLを含み、かつMNOとPQRも含む」\n!ABC|DEF GHI|JKL MNO PQR\n";
var filterSampleWord = SITEINFO[thissite].filterSampleWord || "";
//県民性専用機能
if (location.href.match(/:\/\/todo-ran\.com\/t\/kiji\//)) { $("div.kiji>div:eq(2)").after($("a:contains('全ての相関を見る'):first").clone().css("float", "right")); } // ?
if (location.href.match(/:\/\/todo-ran\.com\/t\/soukan\//)) $("table#t_soukan_r tbody tr td a,table#t_soukan tbody tr td a").each(function() { $(this).append("<a style='float:right;-moz-user-select: none; -webkit-user-select: none; -ms-user-select: none;' rel=\"noopener noreferrer nofollow\" href='" + $(this).attr("href").replace("kiji", "soukan") + "'>全相関記事を見る</a>") });
// a: 相関係数が0に近いものを消す
if (location.href.match(/:\/\/todo-ran\.com\/t\/soukan\//)) {
$("<span class='phov' style='cursor:pointer; color:#505050; font-size:90%; background:#ffffffc0; padding:3px; border-radius:9px;border:#505050 1px solid; position:fixed; bottom:3em; right: 1em;'>A:相関が弱いものを消す</span>").appendTo(document.body).click(function() { soukan(); });
$(document).off('keydown.soukan').on('keydown.soukan', function(e) {
if (/input|textarea/i.test(e.target.tagName) == false) {
var key = (e.shiftKey ? "Shift+" : "") + (e.altKey ? "Alt+" : "") + (e.ctrlKey ? "Ctrl+" : "") + e.key;
if (key == "a" && $(xa(SITEINFO[thissite].filterItem)).length > 0) {
soukan();
return false;
}
}
});
function soukan() {
var key = proInput("残す個数", 35, 0);
if (key > 1) {
$('tr:hidden').remove();
var min = $(xa('//table[@id="t_soukan_r"]/tbody/tr/td[last()]|//table[@class="kenbetsuranking" and @id="t_soukan"]/tbody/tr/td[2]')).sort(function(a, b) { return Math.abs($(a).text()) > Math.abs($(b).text()) ? 1 : -1; });
for (var i = 0; i < $(min).length; i++) {
if (i < ($(min).length - key)) $(min[i]).parent().hide();
else $(min[i]).parent().show();
}
}
}
}
//チョクバイ!住所一覧ボタン
$('<span style="cursor:pointer; text-align:center; background-color:#ffffff; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; font-size:14px; font-weight:normal; color:#606060; margin:0px 2px; text-decoration:none; text-align:center; padding:0px 7px 1px; border:outset #909090 1px; border-radius:5px; background: linear-gradient(#fefefe, #f4f4f4);" >住所一覧をクリップボードにコピー</span>').appendTo(xa('//div[@class="result-main"]/div/table/tbody/tr/td/h3')).on('click', function(e) {
if ($(xa(SITEINFO[thissite].mapPlace))) {
var maplist = [];
$(xa(SITEINFO[thissite].mapPlace)).each(function() {
maplist.push($(this).text().trim().replace(/\s|地図|付近/gmi, ""));
})
maplist = Array.from(new Set(maplist)).sort();
alert(Array.from(new Set(maplist)).sort().join("\r\n"));
GM.setClipboard(Array.from(new Set(maplist)).sort().join("\r\n"));
}
})
//地図検索機能
if ($(xa(SITEINFO[thissite].mapPlace))) $(xa(SITEINFO[thissite].mapPlace)).each(function() { $(this).append("<a class='shibo' style='text-align:center; background-color:#ffffff; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; font-size:14px; font-weight:normal; color:#606060; margin:0px 2px; text-decoration:none; text-align:center; padding:0px 7px 1px; border:outset #909090 1px; border-radius:5px; background: linear-gradient(#fefefe, #f4f4f4); float:right;' rel=\"noopener noreferrer nofollow\" href='https://www.google.co.jp/maps/search/" + $(this).text().replace(/\s+/gmi, "") + "'>地図</a>"); });
//検索窓設置場所と対象項目が1つでもあれば
if ($(xa(SITEINFO[thissite].filterPlace)).length && $(xa(SITEINFO[thissite].filterItem)).length) {
var shiboPrompt = function(key) {
var kw = prompt("絞り込みキーワード(正規表現)\n\n例:\n" + filterSampleWord + /*"\n\n現在値:\n" + (pref("defWord") || "") +*/ "\n\n履歴:\n" + (pref("defWordLog") || []).slice(0, historyLen).join("\n") + "\n\n" + tips + "\n\n", pref("defWord") || "");
if (kw !== null) {
shibo(prefl("defWord", kw), key);
$("#sear").val(kw || "");
} else {
shibo("");
$("#sear").val(kw || "");
}
}
// 絞り込みフォームを付ける
$('<span ID="shiboButton" class="shibo" title="S or Shift+Alt+S" style="cursor:pointer; background-color:#999999; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; font-size:13px; font-weight:500; color:#ffffff; margin:0px 2px; text-decoration:none; text-align:center; padding:1px 5px 1px; border:outset #909090 0px; border-radius:5px; ">絞り込み(s)</span><input class="shibo" style="width:80%" type="text" id="sear" accesskey="s" title="' + tips + '" Placeholder="例)' + filterSampleWord + '">').insertAfter($(xa(SITEINFO[thissite].filterPlace)).first()); // autofocus="on"
$("#shiboButton").click(shiboPrompt);
$("#sear").change(() => { shibo(prefl("defWord", $("#sear").val())) });
// 絞り込みショートカットキーイベントを設定
$(document).off('keydown.shibo').on('keydown.shibo', function(e) {
if (/input|textarea/i.test(e.target.tagName) == false && ($(xa(SITEINFO[thissite].filterPlace)).length && $(xa(SITEINFO[thissite].filterItem)).length)) {
var key = (e.shiftKey ? "Shift+" : "") + (e.altKey ? "Alt+" : "") + (e.ctrlKey ? "Ctrl+" : "") + e.key;
if ((key === HIGHLIGHT_KEY || key === SITEINFO[thissite].highlightKey || key == "s") && $(xa(SITEINFO[thissite].filterItem)).length > 0) {
shiboPrompt(key);
return false;
}
}
});
}
return;
//絞り込む
//DOM追加を監視
function shibo(sear = "", key = "s") {
if (sear === "") {
if (shiboDNIevent) {
document.body.removeEventListener('DOMNodeInserted', shiboDNIevent);
shiboDNIevent = null;
}
shibo3("", key);
} else {
shibo3(sear, key);
if (shiboDNIevent) document.body.removeEventListener('DOMNodeInserted', shiboDNIevent);
shiboDNIevent = { handleEvent: shibo2, arg1: sear };
document.body.addEventListener('DOMNodeInserted', shiboDNIevent, false);
}
}
function shibo2() { shibo3(this.arg1); }
function shibo3(sear = "", key = "s") {
var node = document;
if (shiboTimer) return;
shiboTimer = setTimeout(function() {
if (!($(xa(SITEINFO[thissite].filterPlace)) && $(xa(SITEINFO[thissite].filterItem)).length)) return;
// $("#sear").val(sear);
searRE = sear.replace(/|/gm, "|").replace(/^[\!|!](\S*)/, "^(?!.*($1)).*").replace(/(\S*)[ ](\S*)/gm, "^(?=.*($1))(?=.*\($2\))").replace(/\s| /gm, ".*"); //alert(searRE);
try {
if ((key === HIGHLIGHT_KEY || key === SITEINFO[thissite].highlightKey) && sear && document.body.innerText.match(new RegExp(searRE, "gmi"))) {
document.body.innerHTML = document.body.innerHTML.replace(new RegExp(searRE, "gmi"), '<span class="gcs" style="background-color:#ffff00">$&</span>');
}
$(xa(SITEINFO[thissite].filterItem, node)).each((function(len, sear) {
return function() {
var ele = $(this);
// if (ele.css("opacity") == 0 || !(ele.text().replace(/\r|\n|\s/gm, " ").match(new RegExp(searRE, "gmi")))) {
if (ele[0].dataset.hidden == "1" || !(ele.text().replace(/\r|\n|\s/gm, " ").match(new RegExp(searRE, "gmi")))) {
SITEINFO[thissite].important ? ele.attr("style", "display:none !important;") :
len < 50 ? ele.hide(200) : len > 200 ? ele.hide() : ele.fadeOut(200);
} else {
// SITEINFO[thissite].important ? ele.attr("style", "display:block !important;") :
len < 50 ? ele.show(200) : len > 200 ? ele.show() : ele.fadeIn(200);
}
}
})($(xa(SITEINFO[thissite].filterItem)).length, sear))
} catch (e) { alert("おそらく正規表現の構文エラーです\n" + searRE); }
shiboTimer = 0;
if (typeof SITEINFO[thissite].filterFunc === "function") SITEINFO[thissite].filterFunc(); // サイトごとの特殊処理があれば
}, 200);
}
function prefl(name, store = undefined, logLen = 100) { // prefl(name,data,len)で書き込み(数値でも文字列でも配列でもオブジェクトでも可)・"name+Log"にlen個の履歴保存、pref(name)で読み出し
if (store === undefined) { // 読み出し
return pref(name);
} else { // 書き込み、削除
if (store) {
var a = pref(name + "Log") || [];
a.unshift(store);
a = Array.from(new Set(a));
pref(name + "Log", a.slice(0, logLen));
}
return pref(name, store);
}
}
function pref(name, store = undefined) { // pref(name,data)で書き込み(数値でも文字列でも配列でもオブジェクトでも可)、pref(name)で読み出し
var domain = (location.href.match(/^https?:\/{2,}(.*?)(?:\/|\?|#|$)/)[1] || location.href);
if (store === undefined) { // 読み出し
let data = GM_getValue(domain + " ::: " + name)
if (data == undefined) return store; // 値がないなら終わり
if (data.substr(0, 1) === "[") { // 配列なのでJSONで返す
try { return JSON.parse(data || '[]'); } catch (e) {
alert("(読み出し)データベースがバグってるのでクリアします\n" + e);
pref(name, null);
return null;
}
} else return data;
}
if (store === "" || store === [] || store === null) { // 書き込み、削除
GM_deleteValue(domain + " ::: " + name);
return store;
} else if (typeof store === "string") { // 書き込み、文字列b
GM_setValue(domain + " ::: " + name, store);
return store;
} else { // 書き込み、配列
try { GM_setValue(domain + " ::: " + name, JSON.stringify(store)); } catch (e) {
alert("(書き込み)データベースがバグってるのでクリアします\n" + e);
pref(name, "");
return null;
}
return store;
}
// return store;
}
}
function xa(xpath, node = document) {
if (!xpath) return [];
if (xpath.match(/^\//)) {
try {
var array = [];
var ele = document.evaluate("." + xpath, node, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < ele.snapshotLength; i++) array[i] = ele.snapshotItem(i);
return array;
} catch (e) { return []; }
} else {
return $(xpath);
}
}
function proInput(prom, defaultval, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
return Math.min(Math.max(
Number(window.prompt(prom, defaultval).replace(/[A-Za-z0-9.]/g, function(s) { return String.fromCharCode(s.charCodeAt(0) - 65248); }).replace(/[^-^0-9^\.]/g, "")), min), max);
}
function elegeta(xpath, node = document) {
if (!xpath) return [];
try {
var array = [];
var ele = document.evaluate("." + xpath, node, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < ele.snapshotLength; i++) array[i] = ele.snapshotItem(i);
return array;
} catch (e) { return []; }
}
})()