Greasy Fork is available in English.

学園祭カレンダー絞り込み

s:絞り込み(h:強調付き) (とどラン)a:相関が弱いものを消す

Устаревшая версия на 29.07.2022. Перейти к последней версии.

// ==UserScript==
// @name 学園祭カレンダー絞り込み
// @description s:絞り込み(h:強調付き) (とどラン)a:相関が弱いものを消す
// @version      0.3.38
// @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 *://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/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.nicovideo.jp/my/
// @match https://www.nicovideo.jp/my/nicorepo/*
// @match *://www.nicovideo.me/*
// @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 *://kuzure.but.jp/*
// @match *://*.userbenchmark.com/*
// @match *://commons.nicovideo.jp/*
// @match *://scholar.google.co.jp/*
// @match *://pubmed.ncbi.nlm.nih.gov/*
// @match *://www.amazon.co.jp/s?k=*
// @match *://www.amazon.co.jp/s?*
// @match *://www.suruga-ya.jp/*
// @match *://www.onsen.ag/
// @match *://hibiki-radio.jp/*
// @match *://shopping.yahoo.co.jp/search*
// @match *://the360.life/*
// @match https://www.nicovideo.jp/my/?ref=pc_mypage_menu
// @match *://refind2ch.org/*
// @match *://kakaku.com/specsearch/*
// @match *://www.pixiv.net/users/*
// @match *://greasyfork.org/*/scripts*
// @match *://*.ftbucket.info/*
// @match *://boards.4channel.org/*
// @match *://*.2chan.net/*
// @match *://www.amazon.co.jp/*/product-reviews/*
// @match *://ff5ch.syoboi.jp/?q=*
// @match *://www.youtube.com/watch?v=*
// @match *://togetter.com/*
// @match *://togetter.com/search*
// @match *://www.yodobashi.com/?word=*
// @match *://www.yodobashi.com/*&word=*
// @match *://www.yodobashi.com/*?word=*
// @match *://www.sukima.me/*
// @match *://webcomics.jp/*
// @match *://twicomi.com/*
// @match *://free.arinco.org/*
// @match *://write.as/*
// @match *://*.writeas.com/*
// @match *://en.wikipedia.org/*
// @match *://workman.jp/*
// @match *://www.uniqlo.com/*
// @match *://*.shitaraba.net/bbs/read.cgi/*
// @match *://jbbs.shitaraba.net/bbs/read_archive.cgi/*
// @match *://anige.horigiri.net/*
// @match *://futapo.futakuro.com/*
// @match *://www.ftbucket.info/*
// @match *://jp.iherb.com/search?kw=*
// @match *://jp.iherb.com/c/*
// @match *://my-best.com/*
// @match *://www.rtings.com/*
// @match *://my-best.com/*
// @match https://kakaku.com/pc/note-pc/itemlist.aspx
// @match https://kakaku.com/pc/desktop-pc/itemlist.aspx
// @grant       GM_setValue
// @grant       GM_getValue
// @grant       GM_deleteValue
// @grant       GM.setClipboard
// @grant       GM_addStyle
// @require https://code.jquery.com/jquery-3.4.1.min.js
// @namespace https://greasyfork.org/users/181558
// ==/UserScript==

(function() {
  const historyLen = 250;
  const historyLenMax = 500;
  const HIGHLIGHT_KEY = null; // "h"; // すべてのサイトでのハイライト付き絞り込みのキーのデフォルト
  const EXPERT = 0;
  //  const CLOSEST_TO_IGNORED=[".ignoreFilter",".post_hover"];
  const LogMatch = 0;
  const WAIT = performance.now();
  const debug = 0; // 1:フィルタのボタン・フォーム設置予定地と対象要素を強調
  var popupY = 0;

  String.prototype.match0 = function(re) { let tmp = this.match(re); if (!tmp) { return null } else if (tmp.length > 1) { return tmp[1] } else return tmp[0] } // gフラグ不可
  let inYOUTUBE = location.hostname.match0(/^www\.youtube\.com|^youtu\.be/);

  if (window !== parent) return;

  const SITEINFO = [ // 上が優先
    {
      url: '//my-best.com/',
      filterPlace: '//h1[@class="c-kiji__h1"]',
      filterItem: '//div[@class="p-contents-item-part"]',
    }, {
      url: /^https:\/\/kakaku.com\/pc\/note-pc\/itemlist\.aspx|https:\/\/kakaku\.com\/pc\/desktop-pc\/itemlist.aspx/,
      filterPlace: '//form[@method="post"]/div/table',
      filterItem: '//table/tbody/tr/td[@class="ckitemLink"]/ancestor::tr[@class="tr-border"]',
      altFilter: (searRE) => {
        elegetaG('//table/tbody/tr/td[@class="ckitemLink"]/ancestor::tr[@class="tr-border"]').filter(e => eleget0('.end.checkItem', e)).forEach(e => {
          if (new RegExp(searRE, "gmi").test((e.innerText + " " + e?.nextSibling?.nextSibling?.innerText).replace(/\r|\n|\s/gm, " "))) { $(e?.nextSibling?.nextSibling).add(e).show(); } else { $(e?.nextSibling?.nextSibling).add(e).hide(); }
        })
      },
      dniWait: 500,
      delay: 1222,
      //      ignoreAbsenceOfItem: 1,
    }, {
      url: /\/\/www.rtings.com\/.*\/table/,
      filterPlace: '//div[@class="table_tool-header"]/div[1]',
      filterItem: '//div/table[@class="simple_table-table"]/tbody/tr',
      dniWait: 500,
      delay: 3222,
      style: 'width:44%;'
    }, {
      url: '//my-best.com/',
      filterPlace: '//ul[@class="js-cluster-list p-cluster-select__list"]',
      filterItem: '.p-content-box tbody tr',
      delay: 999,
    }, {
      url: /\/\/jp.iherb.com\/search\?kw=|\/\/jp.iherb.com\/c\//,
      filterPlace: '//div[@class="text-danger-lighter"]',
      filterItem: '//div[@class="products clearfix"]/div',
      delay: 999,
    }, {
      url: '//futapo.futakuro.com/',
      filterPlace: '//div[@id="menu"]/header/ul/li[last()]',
      filterItem: 'div#data>a.box',
      delay: 500,
      style: "width:7em;",
      ignoreAbsenceOfItem: 1,
    }, {
      url: /https:\/\/www.ftbucket.info\/scrapshot\/ftb\/index.php|www.ftbucket.info\/scrapshot\/ftb\/\?favo=0|\/\/www.ftbucket.info\/scrapshot\/ftb\/$/,
      id: 'ftbucket_catalog',
      filterPlace: '//body/form[@class="ng-pristine ng-valid"]/div|//html/body/div[5]',
      filterItem: '//html/body/table[2]/tbody/tr/td',
      delay: 200,
    }, {
      url: '//www.uniqlo.com/',
      filterPlace: '//nav/ol[@class="uq-uikit-breadcrumb-group"]',
      filterItem: '//div/div[@data-test="product-grid"]/div',
    }, {
      url: '//en.wikipedia.org/',
      filterItem: '//table/tbody/tr',
      filterPlace: '//h1[@id="firstHeading"]',
      highlightKey: "h",
    }, {
      url: '//write.as/|writeas.com',
      filterPlace: '//header',
      filterItem: '//article',
      highlightKey: "h",
    }, {
      url: '//free.arinco.org/',
      filterItem: '//ul[@class="itemlist reduce"]/li|//li/a/..|//div/ol[@class="recommended-list"]/li',
      filterPlace: '//div[@id="top"]/nav',
    }, {
      id: 'twicomi',
      url: /\/\/twicomi\.com\/$|\/\/twicomi\.com\/trending\/|\/\/twicomi\.com\/ranking\/|\/\/twicomi\.com\/all\/|\/\/twicomi\.com\/author\//,
      filterPlace: '//div/header/div[@class="sub-menu clearfix"]|//h1[@class="headline-large"]',
      filterItem: '//div[@class="manga-item"]',

      delay: 2000,
      ignoreAbsenceOfItem: 1,
      filterFunc: () => { $('.list').css({ "min-height": "0px" }) }, // AP継ぎ足し時の空白を詰める
      //  observeURL:2000,
    }, {
      id: 'webcomics bookmark',
      url: '//webcomics.jp/bookmark',
      filterPlace: '//div[@class="about"]|//div[@id="pr"]',
      filterItem: '//div[@class="entry"]',
    }, {
      id: 'webcomics.jp',
      url: '//webcomics.jp/',
      filterPlace: '//div[@class="about"]|//div[@id="pr"]',
      filterItem: '//div[@class="entry"]',
      filterSampleWord: 'S|●',
    }, {
      url: '//www.sukima.me/',
      filterPlace: '//h3[@class="h3 py-3 ma-0"]|//div[@class="v-toolbar__extension"]',
      filterItem: '//div[@class="col col-4 col-sm-2 px-1 px-sm-2 z-index-2 my-2"]',
    }, {
      //      url: /\/\/www.yodobashi.com\/\?word=/,
      url: /\/\/www.yodobashi.com\/.*[\&\?]word=/,
      filterPlace: '//div[@class="txtnav clearfix"]',
      filterItem: '//div[@class="srcResultItem spt_hznList tileTypeList js_productList changeTile"]/div',
      altFilter: (searRE) => {
        elegetaG('//div[@class="srcResultItem spt_hznList tileTypeList js_productList changeTile"]/div').filter(e => eleget0('//a/div[@class="pName fs14"]', e)).forEach(e => {
          if (new RegExp(searRE, "gmi").test((eleget0('//a/div[@class="pName fs14"]', e).innerText).replace(/\r|\n|\s/gm, " "))) { $(e).show(); } else { $(e).hide(); }
        })
      },

    }, {
      url: '//togetter.com|//togetter.com/search',
      filterPlace: '//header[@class="header_top"]/div',
      filterItem: '//article/div[@class="tweet_box"]/div|.//div[@class="list_box impl_profile"]|.//div/div[@class="thumb_list_box"]/div[2]/ul/li/a|.//a[@data-ga="inbound_realtimerank"]/div|.//div[@class="main_box closed"]/ul/li/a|.//ul/li[@class="clearfix"]/a[@data-ga="inbound_commentpopular_link"]|.//div[@class="related_list_box"]/ul/li|.//ul[@class="simple_list"]/li|.//div/div[@class="tag_box"]/a|.//div[@class="popular_tag_box"]/a|.//ul[@class="simple_list ranking_list"]/li|.//div[2]/div[contains(@class,"thumb_list_box")]/div/ul/li/a|.//ul[@class="simple_list insert_recommend"]/li|.//ul[@class="simple_list simple_mini_list"]/li|.//li[@class="has_thumb pickup_picture_list"]',
      //highlightKey:"h",
    }, { // youtubeコメント 絞り込み後のページ移動に全く未対応
      id: 'youtube_comment',
      url: /\/\/www\.youtube\.com\/watch\?v=/,
      filterPlace: '//ytd-video-secondary-info-renderer|//div[@id="owner-and-teaser"]',
      filterItem: '//div[@id="main"]/..', //'//div[@id="content"]/../../..',
      ignoreAbsenceOfItem: 1,
      dniWait: 700, // ヤフオクのdelayより大きくすること
      delay: 4000,
      disableKey: 1, // video speed controllerと衝突するのでsキーは無効
    }, {
      url: /\/\/ff5ch\.syoboi\.jp\/\?q=/,
      filterPlace: '//section[2]/div',
      filterItem: '//a[@class="thread"]/../..',
      highlightKey: "h",
    }, {
      id: 'amazon_review',
      url: '//www.amazon.co.jp/.+/product-reviews/.+',
      filterItem: '//div[contains(@class,"a-section celwidget")]/..',
      filterPlace: '//div/div[1]/div/div[@data-hook="cr-filter-info-review-rating-count"]',
    }, {
      url: '//greasyfork.org/.+/scripts',
      filterPlace: '//div[@class="sidebarred-main-content"]/p[1]',
      filterItem: '//a[@class="script-link"]/../../..',
    }, {
      url: '//www.pixiv.net/users/',
      filterPlace: '//section/div[2]/div|//h2[@font-size="20" and @color="text2"]/..',
      filterItem: '//div/div/ul/li[@offset="0"]',
      delay: 3000,
    }, {
      url: '//boards.4channel.org/',
      filterItem: '//div[@class="postContainer replyContainer"]',
      filterPlace: '//body/div[@id="ctrl-top"]|//div[@class="navLinks desktop"]',
      filterSampleWord: '\\d\\s(K|M)B',
    }, {
      url: '//kakaku.com/specsearch/',
      filterPlace: '//div[@class="checkButton"]|//div[@id="selectView"]',
      filterItem: '//td[@class="textL"]/strong/a/../../..',
      //delay:1000,
    }, {
      url: '//refind2ch.org/',
      filterPlace: '//div[@id="search_option"]',
      filterItem: '//div[3]/div/div[@id="search_results"]/a',
      dniWait: 777,
      highlightKey: "h",
    }, {
      url: '//the360.life/',
      filterPlace: '//div/div[@class="s-ttl"]/img/..',
      filterItem: '//div[@class="s-ls2_list"]',
      filterSampleWord: '!化粧|コスメ|美容',
      dniWait: 200,
      delayAutoWeighting: 1,
    }, {
      url: '//shopping.yahoo.co.jp/search',
      filterPlace: '//div/div[1]/h1',
      filterItem: '//li[@class="LoopList__item"]/div',
      delayAutoWeighting: 1,
      delay: 1000,
    }, {
      url: '//hibiki-radio.jp/',
      filterPlace: '//div[@class="tabset"]',
      filterItem: '//div/a[contains(@class,"program-box program-box-animate")]',
      delayAutoWeighting: 3,
    }, {
      url: '//www.onsen.ag',
      filterPlace: '//ul[@id="tabs"]', //'//div[@class="category--container"]',
      filterItem: '//div[@class="category-videos--wrapper"]/ul/li/..|//div[@class="slide-item"]/div/..|//ul[@class="category-videos"]/li|//a[@class="recommend-item-link"]|//ul[@class="category-videos count-videos"]/li|//a[@class="recommend-item-link"]|//a[@class="event-item-link"]',
      delayAutoWeighting: 1,
    }, {
      url: '//www.suruga-ya.jp/search',
      filterPlace: '//div[@class="search_option"]',
      filterItem: '//div[@class="item_detail"]/..',
    }, {
      url: /\/\/www\.amazon\.co\.jp\/s\?k=/,
      filterPlace: '//div[@class="a-section a-spacing-small a-spacing-top-small"]',
      //      filterItem: '//span[@class="a-size-base-plus a-color-base a-text-normal"]/../../../../../../../..',
      //      filterItem: '//span[@class="a-size-base-plus a-color-base a-text-normal"]/../../../../../../..', // 無難
      //      filterItem: '//span[@class="a-size-base-plus a-color-base a-text-normal"]/../../../../../../../..', // 詰め気味
      //filterItem: '//div[@class="sg-col-4-of-12 s-result-item s-asin sg-col-4-of-16 sg-col s-widget-spacing-small sg-col-4-of-20"]',//'//div[@class="a-section a-spacing-none"]/div[1]/h2/a[@class="a-link-normal a-text-normal"]/span/ancestor::div[contains(@class,"sg-col-4-of-12 s-result-item")]|//span[@id="productTitle"]/ancestor::div[contains(@class,"sg-col-4-of-12 s-result-item")]|//h1[@id="title"]/span[@id="productTitle"]/ancestor::div[contains(@class,"sg-col-4-of-12 s-result-item")]', // ancestor
      filterItem: '//div[contains(@class,"s-result-item s-asin")]', //'//div[@class="a-section a-spacing-none"]/div[1]/h2/a[@class="a-link-normal a-text-normal"]/span/ancestor::div[contains(@class,"sg-col-4-of-12 s-result-item")]|//span[@id="productTitle"]/ancestor::div[contains(@class,"sg-col-4-of-12 s-result-item")]|//h1[@id="title"]/span[@id="productTitle"]/ancestor::div[contains(@class,"sg-col-4-of-12 s-result-item")]', // ancestor
    }, {
      url: '//pubmed.ncbi.nlm.nih.gov/',
      filterPlace: '//div[@class="results-amount-container"]/div[1]',
      filterItem: '//article[@class="full-docsum"]',
    }, {
      url: '//scholar.google.co.jp',
      filterPlace: '//div[@id="gs_ab_md"]/div/../..',
      filterItem: '//div[contains(@class,"gs_r gs_or gs_scl")]',
    }, {
      id: 'nicorepo',
      url: '//www.nicovideo.jp/my/\\?ref=pc_mypage_menu|https://www\.nicovideo\.jp\/my\/$|https:\/\/www\.nicovideo\.jp\/my\/nicorepo\/',
      filterPlace: '//div[@class="MainMenuContainer-menu"]',
      filterItem: '//div/article[@class="NicorepoItem-item"]/..',
      delayAutoWeighting: 1.75,
      filterSampleWord: '投稿しました',
      filterFunc: function() { $('.NicorepoItem-item').css({ "padding": "0px" }) }, // 余白を詰める
      ignoreAbsenceOfItem: 1,
    }, {
      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: '',
      highlightKey: "h",
    }, {
      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: 2000,
      highlightKey: "h",
    }, {
      url: '//.*\.5ch\.net/',
      filterPlace: '//h1[@class="title"]|//span/h1',
      filterItem: '//div[@class="post"]',
      delay: 750,
      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: '\.shitaraba\.net\/bbs\/read\.cgi\/|\.shitaraba\.net\/bbs\/read_archive\.cgi\/',
      filterPlace: '//h1[@class="thread-title"]|/html/body/p/a[text()="■過去ログ倉庫一覧■"]|//div[@class="header-menu"]',
      filterItem: '//div[@class="post"]',
      delay: 1000,
      //      important: true,
      filterFunc: function() {
        $('div.post:hidden').next("br").css("display", "none");
        $('div.post:visible').next("br:hidden").css("display", "block");
      }, //余計な改行を詰める
      //filterFuncDelay:1,
      highlightKey: "h",
      filterSampleWord: 'ttp',
    }, {
      //      url: '//.*?.2chan.net/|//.*.ftbucket.info/scrapshot/ftb/cont/', // ftbucketでは全show()のCSSStyleDeclaration.getPropertyValueが異様に重い
      url: '//.*?.2chan.net/|//.*.ftbucket.info/.+/cont/', // ftbucketでは全show()のCSSStyleDeclaration.getPropertyValueが異様に重い
      id: 'futachan',
      fastShow: 200,
      filterPlace: '/HTML/BODY/HR[2]',
      filterItem: '//tr/td[@class="rtd"]/../../..|//span[@class="cnw"]',
      filterSampleWord: 'B\\)|そうだねx|>>\\d',
      highlightKey: "h",
      highlightXP: '.rtd',
      style: 'width:calc(100% - 50em);'
    }, {
      //      url: '//.*?.2chan.net/|//.*.ftbucket.info/scrapshot/ftb/cont/', // ftbucketでは全show()のCSSStyleDeclaration.getPropertyValueが異様に重い
      url: '//anige.horigiri.net', // ftbucketでは全show()のCSSStyleDeclaration.getPropertyValueが異様に重い
      id: 'futachan',
      fastShow: 200,
      filterPlace: '//div/div[@class="titlebox"]',
      filterItem: '//div/table/tbody/tr/../..',
      filterSampleWord: 'B\\)|そうだねx|>>\\d',
      highlightKey: "h",
    }, {
      url: '//kuzure.but.jp/',
      id: 'futachan',
      filterPlace: '//div[@id="head"]/hr',
      filterItem: '//tr/td[@class="rtd"]/../../..',
      filterSampleWord: 'B\\)|そうだねx',
      highlightKey: "h",
      style: 'width:calc(100% - 40em);'
    }, {
      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"]|//div[@class="CheckboxVideoMediaObject WatchLaterListItem WatchLaterList-item CheckboxVideoMediaObject_withFooter"]|//div[@class="VideoMediaObjectList"]/div',
      delay: 1000,
      delayAutoWeighting: 2,
      observeURL: 6, // よくわからないけど要リロード
      ignoreAbsenceOfItem: 1,
    }, {
      url: '//www.nicovideo.jp/user/.+/mylist/', // 様子見
      filterPlace: '//h1[@class="MylistHeader-name"]',
      filterItem: '//div[@class="VideoMediaObject MylistItem MylistItemList-item"]|//div[@class="NC-MediaObject-body"]/div[@class="NC-MediaObject-bodyTitle"]/h2/../../../../..',
      //      delayAutoWeighting:5,
      observeURL: 6, // よくわからないけど要リロード
      delay: 3000,
      ignoreAbsenceOfItem: 1,
    }, {
      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: '//div[@class="product-container"]/div/a',
      filterPlace: '//div[@class="top-container"]|//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: "消費量",
      funcOnRun: () => {
        //県民性専用機能
        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>") });
        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).after("<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='phovTodoran' 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) {
            if (e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA' && e.target.getAttribute('contenteditable') != 'true') {
              var key = (e.shiftKey ? "Shift+" : "") + (e.altKey ? "Alt+" : "") + (e.ctrlKey ? "Ctrl+" : "") + e.key;
              if (key == "a" && $(xa(SITE.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();
              }
            }
          }
        }
      },
    }, {
      url: "//fmfm.jp",
      filterPlace: '//dl[@class="dateSort"]',
      filterItem: '//section[@class="eventList"]',
      filterSampleWord: "東京",
      delayAutoWeighting: 2.5,
    }, {
      url: "//www.nicovideo.jp/ranking",
      filterItem: '//div[@class="NC-Card-mainHeader"]/a/h2/../../..|.//div/div/h2[@class="NC-MediaObjectTitle NC-VideoMediaObject-title NC-MediaObjectTitle_fixed2Line"]/../../../../..',
      filterPlace: '//ul[@class="RankingGenreListContainer"]|//section[@class="RankingHeader SpecifiedRankingHeaderContainer"]', //'//div[@class="RankingHeaderContainer-headerInner"]',
      //    filterPlace: "div.BaseLayout-block ul",
      //      filterItem: '//div[@class="Card-title"]/..',
      filterSampleWord: "!ゆっくり 解説|講座",
      filterFunc: () => {
        GM_addStyle('.RankingMatrixVideosRow{height:auto;min-height:1.5em;} .RankingMatrixNicoadsRow{height:auto;} .VideoItem.NC-VideoCard{height:auto;} .MatrixRanking-app{min-height:auto;}'); // 余白を詰める
      },
    }, {
      url: "//www.youtube.com/results",
      ignoreAbsenceOfItem: 1,
      delayAutoWeighting: 1,
      delay: 1500,
      filterPlace: '//div[@id="filter-menu"]',
      //filterItem: '//div[@id="content"]/*/div[@id="dismissible"]/../../..|.//div[@id="dismissible"]/..|.//ytd-playlist-renderer|.//ytd-channel-renderer|.//ytd-movie-renderer|.//ytd-horizontal-card-list-renderer',
      filterItem: '//ytd-radio-renderer|//ytd-video-renderer|//ytd-playlist-renderer|//ytd-channel-renderer|//ytd-movie-renderer|//ytd-horizontal-card-list-renderer',
      observeURL: 3,
      //      filterSampleWord: "\\d\\d\\d\\d.\\d\\d.\\d\\d.\\(.\\)\n!\\d\\s年前|\\d\\sか月前|\\d\\s週間前|\\D[2-9]\\s日前|再生リストの全体を見る|\\d\\s本の動画|ミックスリスト|チャンネル登録者数",

      //      dniWait:1000,
    }, {
      url: "//www.youtube.com/channel/.*/search|//www.youtube.com/user/.*/search|//www.youtube.com/c/.*/search",
      filterPlace: '//input[@class="style-scope paper-input"]|//button[@id="button" and @aria-label="検索"]',
      filterItem: '//*[@class="style-scope ytd-section-list-renderer"]',
      observeURL: 3,
      //filterSampleWord: "!\\d\\s年前|\\d\\sか月前|\\d\\s週間前",

      ignoreAbsenceOfItem: 1,
      delayAutoWeighting: 1,
      delay: 1500,
    }, {
      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週間前",

      ignoreAbsenceOfItem: 1,
      delayAutoWeighting: 1,
      delay: 1500,
    }, {
      url: "//www.youtube.com/playlist\?",
      filterPlace: '//div[@id="items"]/ytd-playlist-sidebar-secondary-info-renderer',
      //      filterItem: '//*[@class="style-scope ytd-playlist-video-list-renderer"]',
      filterItem: '//div/ytd-playlist-video-list-renderer/div[@id="contents"]/ytd-playlist-video-renderer',
      observeURL: 3,

      ignoreAbsenceOfItem: 1,
      delayAutoWeighting: 1,
      delay: 1500,
    }, {
      id: "YOUTUBE_TOP",
      url: "//www.youtube.com/$",
      filterPlace: '//div[@id="header" and @class="style-scope ytd-rich-grid-renderer"]', //'//div[@id="sections"]/ytd-guide-section-renderer[2]',////'//span[@id="title" and text()="あなたへのおすすめ"]', //'span#title:contains("あなたへのおすすめ"):visible',
      //      filterItem: '//div[@id="dismissible"]/../../..',
      filterItem: '//ytd-rich-item-renderer',
      observeURL: 3,
      delayAutoWeighting: 0.2,
      ignoreAbsenceOfItem: 1,
      delay: 1500,
      filterSampleWord: "!\\d\\s年前|\\d\\sか月前|\\d\\s週間前|\\D[2-9]\\s日前|\\d\\d\\s日前|再生リストの全体を見る|\\d\\s本の動画|ミックスリスト|人が視聴中|YouTube\\sMusic",
    }, {
      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|/shop/storereserve/",
      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",
      mapPlace: '//div[@class="block-stock-result--shopinfo"]/p[2]',
      observeURL: 1,
      delay: 1500,
    }, {
      url: "//www.nicovideo.jp/user/", // 2021年04月29日リニューアル用 様子見
      filterPlace: '//header[@class="VideoContainer-header"]|//span[@class="VideoContainer-headerTotalCount"]|//div[@class="MainMenuContainer-menuList"]',
      filterItem: '//div[@class="VideoMediaObject-body"]/span/../../../..|//div[@class="MediaObject-bodyTitle"]/h2/../../../../..|//article[@class="NicorepoItem-item"]/..|//div[@class="NC-MediaObject-body"]/div[@class="NC-MediaObject-bodyTitle"]/h2/../../../../..',
      delayAutoWeighting: 2, //      delay: 1000,
      /*}, {
          url: "//www.nicovideo.jp/user/",
          filterPlace: "div.outer.VideoListHeadMenuContainer",
          filterItem: '//div[@class="outer VideoItem"]',
      */
    }, {
      url: '//www.nicovideo.jp/tag/',
      filterPlace: '//div[@class="tagListBox"]|//div[@class="formSearch"]',
      filterItem: '//li[@data-nicoad-video=""]', // '//li[@class="item"]',
    }, {
      url: '//www.nicovideo.jp/search/',
      filterPlace: '//div[@class="tagListBox"]|//div[@class="formSearch"]',
      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分|1日',
    }, {
      url: '//auctions.yahoo.co.jp/seller/',
      filterPlace: '//div[@class="bd"]/..',
      filterItem: '//td[@class="i"]/..',
      filterSampleWord: '!認証制限.:あり \\d時間|\\d分|1日',
    }, {
      url: '//auctions.yahoo.co.jp/category/list/',
      filterPlace: '//div[@class="Options"]',
      filterItem: '//li[@class="Product"]',
      filterSampleWord: '!認証制限.:あり \\d時間|\\d分|1日',
    }, {
      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/',
      id: 'OWATA_ANTENNA',
      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',
      id: 'OWATA_ANTENNA',
      filterPlace: '//div/div[@class="clearfix"]',
      filterItem: '//div[@class="feed clearfix"]|//div[@class="feed-list"]/div',
    }, {
      url: '//oowata.com',
      id: 'OWATA_ANTENNA',
      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: '//div[@class="s-item__wrapper clearfix"]/..', //'//li[@class="s-item    "]/div/..',
      filterSampleWord: 'top.rated.seller|トップレートの売り手 \\d.product.rating|の製品評価',
    }, {
      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,
    },
    /* {
                id: '', // 入力履歴を保存するキー名 省略時はサイトのドメイン(省略可)
                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以外ならページ開始時から処理開始までの遅延の係数(省略可) delayと両方指定すると両方のうち大きい方を取る
                dniWait: 0, // 要素が継ぎ足されてから絞り込むまでのウエイトの追加量(省略可)
                disableKeyS: 0, // sキーを無効化
                ignoreAbsenceOfItem: 0, // 1:filterItemが1つも存在しなくても絞り込みフォームを設置
                fastShow:0, // この数以上の項目を隠した後再表示する時にshow()を使わない ftbucketなどで使用.ただしバグるかも(省略可)
                style:"", // 設定されていると絞り込みフォームのstyleを指示 なければ"width:80%"
                altFilter: null, // 設定されていると絞り込み処理をこの関数で実行 kakaku等で使用
        }*/
  ];

  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;
  var SITE;
  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.test(location.href)) {
        if (SITEINFO[i].url === "//.*" && EXPERT == 0) return null;
        thissite = i;
        SITE = SITEINFO[i]
        break;
      }
    }
    return thissite;
  }

  if (LogMatch) console.log(SITEINFO[thissite]);
  if (debug > 2) alert(SITE.url)

  var currentHighlightKey = HIGHLIGHT_KEY || SITE.highlightKey;

  //URL遷移を監視
  var href = location.href;
  var observer = new MutationObserver(function(mutations) {
    if (href !== location.href) {
      href = location.href;
      $(document).off('keydown.shibo');
      $(".shibo").remove();
      thissite = decideThissite();
      if (thissite === null) return;
      if (shiboDNIevent && SITE.observeURL) setTimeout(() => { run("url"); }, 1500)
      for (let i = 0; i < (SITE.observeURL || 1) + 0; i++) setTimeout(run, 1000 + i * 1000);
    }
  });
  observer.observe(document, { childList: true, subtree: true });
  if (SITE.delayAutoWeighting) SITE.delay = Math.min(4000, Math.max(SITE.delay || 0, WAIT * SITE.delayAutoWeighting))
  //alertj("SITE.delay",SITE.delay,debug)
  setTimeout(() => { run() }, SITE.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 = SITE.filterSampleWord || "";

    if (SITE.funcOnRun) SITE.funcOnRun();

    //チョクバイ!住所一覧ボタン
    $('<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(SITE.mapPlace))) {
        var maplist = [];
        $(xa(SITE.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(SITE.mapPlace))) $(xa(SITE.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つでもあるもしくはignoreAbsenceOfItem:1なら
    //if(debug>1){console.log(`(SITE.filterItem).length:${$(xa(SITE.filterItem)).length}`)}
    if (($(xa(SITE.filterItem)).length || SITE.ignoreAbsenceOfItem)) {

      var shiboPrompt = function(key, guide = 0) {
        if (guide) {
          var target = $.makeArray(xa(SITE.filterItem));
          var targetVisible = $(target).filter(":visible").length;
          var targetAll = $(target).length;
          target.forEach(e => debugEle(e, 1));
        }
        var count = targetAll ? `現状:${targetVisible}/${targetAll}\n\n` : "";
        setTimeout(() => {
          //          var kw = prompt(count + "絞り込みキーワード(正規表現)\n\n例:\n" + (filterSampleWord ? filterSampleWord + "\n" : "") + (filterSampleWord !== "\\d\\d\\d\\d.\\d\\d.\\d\\d.\\(.\\)" ? "\\d\\d\\d\\d.\\d\\d.\\d\\d.\\(.\\)\n" : "") + /*"\n\n現在値:\n" + (pref("defWord") || "") +*/ "\n履歴" + "(" + getHistoryKey() + "):\n" + (pref("defWordLog") || []).slice(0, historyLen).join("\n") + "\n\n" + tips + "\n" + (searRE ? "最後の正規表現:\n" + searRE.replace(/\\/g, "\\") : "\n"), pref("defWord") || "");
          var kw = prompt(count + "絞り込みキーワード(正規表現)\n\n例:\n" + (filterSampleWord ? filterSampleWord + "\n" : "") + /*"\n\n現在値:\n" + (pref("defWord") || "") +*/ "\n履歴" + "(" + getHistoryKey() + "):\n" + (pref("defWordLog") || []).slice(0, historyLen).join("\n") + "\n\n" + tips + "\n" + (searRE ? "最後の正規表現:\n" + searRE.replace(/\\/g, "\\") : "\n"), pref("defWord") || "");
          if (guide) $.makeArray(xa(SITE.filterItem)).forEach(e => debugEle(e, 2));
          if (kw !== null) {
            shibo(prefl("defWord", kw), key);
            $("#sear").val(kw || "");
          } else {
            shibo("");
            $("#sear").val(kw || "");
          }
        }, 1) // chromeでは遅らせないとguideが効かない

      }

      if (debug) {
        $.makeArray(xa(SITE.filterItem)).forEach(e => debugEle(e));
        $.makeArray(xa(SITE.filterPlace)).forEach(e => debugEle(e));
      }

      // 絞り込みフォームを付ける
      var form = $(`<span ID="shiboButton" class="ignoreMe 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="ignoreMe shibo" style="${SITE.style||"width:80%"}" type="text" id="sear" accesskey="s" title="${ tips}" Placeholder="例)${filterSampleWord}">`);
      if ($(xa(SITE.filterPlace)).length) { form.insertAfter($(xa(SITE.filterPlace)).first()); } else { form.prependTo($("body")) }

      $("#shiboButton").click(() => { shiboPrompt("s", 1) });
      $("#shiboButton").contextmenu((e) => {
        if (!currentHighlightKey) return;
        shiboPrompt(currentHighlightKey, 1);
        e.stopPropagation();
        return false;
      });
      $("#sear").change(() => { shibo(prefl("defWord", $("#sear").val())) });

      // 絞り込みショートカットキーイベントを設定
      $(document).off('keydown.shibo').on('keydown.shibo', function(e) {
        //if (e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA' && e.target.getAttribute('contenteditable') != 'true') {
        if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || e.target.getAttribute('contenteditable') === 'true' || (inYOUTUBE && (document.activeElement.closest('#chat-messages') || document.activeElement.closest('ytd-comments-header-renderer')))) return;
        var key = (e.shiftKey ? "Shift+" : "") + (e.altKey ? "Alt+" : "") + (e.ctrlKey ? "Ctrl+" : "") + e.key;
        if (!(SITE.disableKey) && (key === HIGHLIGHT_KEY || key === SITE.highlightKey || key == "s") && ($(xa(SITE.filterPlace)).length && $(xa(SITE.filterItem)).length > 0)) {
          shiboPrompt(key);
          e.stopPropagation();
          return false;
        }
        //}
      });
    }
    return;

    //絞り込む
    //DOM追加を監視
    function shibo(sear = "", key = "s") { // フォームEnterかS,Hキーの入り口
      if (shiboTimer) {
        clearTimeout(shiboTimer);
        shiboTimer = null;
      }
      if (sear === "deleteall") {
        if (confirm(getHistoryKey() + "のページの履歴をすべて削除します。よろしいですか?")) {
          pref("defWordLog", null);
          pref("defWord", null)
        }
        return;
      }
      if (sear === "") {
        if (shiboDNIevent) {
          document.body.removeEventListener('DOMNodeInserted', shiboDNIevent);
          shiboDNIevent = null;
        }
        shibo3("", key);
      } else {
        shibo3(sear, key);
        if (shiboDNIevent) document.body.removeEventListener('DOMNodeInserted', shiboDNIevent);
        //if (key !== HIGHLIGHT_KEY && key !== SITE.highlightKey) {
        shiboDNIevent = { handleEvent: shibo2, arg1: sear, arg2: key };
        document.body.addEventListener('DOMNodeInserted', shiboDNIevent, false);
        //}
      }
    }

    function shibo2(e) { // dniイベントで飛んでくる場合の入り口
      //      if (e.target.tagName === "BR" || e.target.className === "phov" || e.target.className === "yhmbox" || e.target.className === "hzP" ) return;
      if (this.arg2 === currentHighlightKey || e.target.tagName === "BR" || (e.target.classList && e.target.classList.contains("ignoreMe"))) return; // ハイライトループを防ぐためハイライトでは監視で再実行しない
      shibo3(this.arg1, this.arg2);
    }

    function shibo3(sear = "", key = "s") {
      var node = document;
      if (shiboTimer) return;
      shiboTimer = setTimeout(function() {
        if (!($(xa(SITE.filterPlace)) && $(xa(SITE.filterItem)).length)) return;
        //        $("#sear").val(sear);
        //        sear=sear.replace(/^S$/,"ഛഥ").replace(/^S([\s \||])/,"ഛഥ$1").replace(/([\s \||!!])S([\s \||])/,"$1ഛഥ$2").replace(/([\s \||!!])S$/,"$1ഛഥ");
        //        searRE = sear.replace(/|/gm, "|").replace(/^[\!|!](\S*)/, "^(?!.*($1)).*").replace(/(\S*)[  ](\S*)/gm, "^(?=.*($1))(?=.*\($2\))").replace(/\s| /gm, ".*"); //alert(searRE); // 独自構文を正規表現に変換

        searRE = sear.replace(/^S$/, "ഛഥ").replace(/^S([\s \||])/, "ഛഥ$1").replace(/([\s \||!!])S([\s \||])/, "$1ഛഥ$2").replace(/([\s \||!!])S$/, "$1ഛഥ").replace(/|/gm, "|").replace(/^[\!|!](\S*)/, "^(?!.*($1)).*").replace(/(\S*)[  ](\S*)/gm, "^(?=.*($1))(?=.*\($2\))").replace(/\s| /gm, ".*"); //alert(searRE); // 独自構文を正規表現に変換

        if (SITE.altFilter) { SITE.altFilter(searRE) } else {
          try {
            elegetaG('//span[@class="gcshl"]').forEach(e => e.outerHTML = e.innerHTML);
            //          if ((key === currentHighlightKey) && sear && document.body.innerText.match(new RegExp(searRE, "gmi"))) { elegetaG(SITE.filterItem).forEach(e => { e.innerHTML = e.innerHTML.replace(new RegExp("(" + searRE + ")(?!([^<]+)?>)", "gmi"), `<span class="gcshl" style="background-color:#ffff00">$1</span>`); }); } // 5ch/mp4等動画を含むと繰り返す
            if ((key === currentHighlightKey) && sear && document.body.innerText.match(new RegExp(searRE, "gmi"))) {
              (SITE.highlightXP ? elegetaG(SITE.filterItem).map(p => eleget0(SITE.highlightXP, p)).filter(c => c) : elegetaG(SITE.filterItem))
              .forEach(e => { e.innerHTML = e.innerHTML.replace(new RegExp("(" + searRE + ")(?!([^<]+)?>)", "gmi"), `<span class="gcshl" style="background-color:#ffff00">$1</span>`); });
            } // 5ch/mp4等動画を含むと繰り返す

            var eles = $.makeArray(xa(SITE.filterItem, node))
            var len = eles.length;
            if (SITE.fastShow && SITE.fastShow < len && sear === "") { eles.forEach(e => e.style.display = null) } else {
              eles.forEach(e => {
                var ele = $(e);
                //              if (e.dataset.hidden == "1" || !(e.textContent.replace(/\r|\n|\s/gm, " ").match(new RegExp(searRE, "gmi")))) {
                if ((e.dataset.hidden == "1" || !(e.textContent.replace(/\r|\n|\s/gm, " ").match(new RegExp(searRE, "gmi")))) && !e.closest(".ignoreFilter")) {
                  //if ((e.dataset.hidden == "1" || !(e.textContent.replace(/\r|\n|\s/gm, " ").match(new RegExp(searRE, "gmi")))) && !CLOSEST_TO_IGNORED.find(c=>e.closest(c)) ) {
                  SITE.important ? ele.attr("style", "display:none !important;") :
                    len < 50 ? ele.hide(200) : len > 200 ? ele.hide() : ele.fadeOut(200);
                } else {
                  len < 50 ? ele.show(200) : len > 200 ? ele.show() : ele.fadeIn(200);
                }
              })
            }
          } catch (e) {
            alert("おそらく正規表現の構文エラーです\n" + searRE + "\n" + e);
            shibo("");
          }
        }
        shiboTimer = 0;
        if (typeof SITE.filterFunc === "function") setTimeout(() => { SITE.filterFunc(); }, (len <= 200 && SITE.filterFuncDelay) ? 300 : 0) // サイトごとの特殊処理があれば
      }, (SITE.dniWait || 0) + 200); // DNI時のウェイトでもある
    }

    function prefl(name, store = undefined, logLen = historyLenMax) { // 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 = [...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 = getHistoryKey(); //SITE.id || 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で返す
        if (isJSON(data)) { // 配列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 isJSON(data) {
    try { JSON.parse(data) } catch { return false }
    return true;
  }

  function getHistoryKey() {
    return (SITE.id || location.href.match(/^https?:\/{2,}(.*?)(?:\/|\?|#|$)/)[1] || location.href);
  }

  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 elegetaG(xpath, node = document) {
    if (!xpath || !node) return [];
    let flag
    if (!/^\.?\//.test(xpath)) return /:visible$/.test(xpath) ? [...node.querySelectorAll(xpath.replace(/:visible$/, ""))].filter(e => e.offsetHeight) : [...node.querySelectorAll(xpath)]
    try {
      var array = [];
      var ele = document.evaluate("." + xpath.replace(/:visible$/, ""), node, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
      let l = ele.snapshotLength;
      for (var i = 0; i < l; i++) array[i] = ele.snapshotItem(i);
      return /:visible$/.test(xpath) ? array.filter(e => e.offsetHeight) : array;
    } catch (e) { popup3(e + "\n" + xpath, 1); return []; }
  }

  function eleget0(xpath, node = document) {
    if (!xpath || !node) return null;
    if (!/^\.?\//.test(xpath)) return node.querySelector(xpath.replace(/:visible$/, ""));
    try {
      var ele = document.evaluate("." + xpath.replace(/:visible$/, ""), node, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
      //      return ele.snapshotLength > 0 ? ele.snapshotItem(0) : "";
      return ele.snapshotLength > 0 ? ele.snapshotItem(0) : null;
    } catch (e) { popup3(e + "\n" + xpath, 1); return null; }
  }

  function debugEle(ele, command = debug) {
    if (command === 1) {
      let col = getColorFromText(ele.textContent);
      buStyle(ele, "outline", "3px dotted " + col)
      buStyle(ele, "boxShadow", " 0px 0px 4px 4px " + col + "30, inset 0 0 100px " + col + "20")
      //ele.style.outline = "3px dotted " + col;
      //ele.style.boxShadow = " 0px 0px 4px 4px " + col + "30, inset 0 0 100px " + col + "20";
    }
    if (command === 2) {
      buStyle(ele, "outline")
      buStyle(ele, "boxShadow")
    }
  }

  function buStyle(ele, key, data = "RESTORE") { // dataがあれば書き込み、なければ回復
    if (data === "RESTORE") {
      if (ele.getAttribute(`${key}Backup`) !== "") { ele.style[key] = ele.getAttribute(`${key}Backup`) } else { ele.style[key] = null }
      ele.removeAttribute(`${key}Backup`)
      if (ele.getAttribute(`styleBackup`) === null) { ele.removeAttribute("style") }
      //ele.removeAttribute("styleBackup")
    } else {
      if (!ele.getAttribute(`${key}Backup`)) {
        ele.setAttribute(`${key}Backup`, ele.style[key])
        ele.setAttribute(`styleBackup`, ele.getAttribute("style"))
      }
      ele.style[key] = data;
    }
  }

  function getColorFromText(str) {
    var col = 0;
    for (letter of str) { col = (col + str.charCodeAt(letter) * 2097152) % 0xffffff; }
    return '#' + (0x1000000 + col).toString(16).substr(1, 6);
  }

  function notifyMe(body, title = "") {
    if (!("Notification" in window)) return;
    else if (Notification.permission == "granted") new Notification(title, { body: body });
    else if (Notification.permission !== "denied") Notification.requestPermission().then(function(permission) {
      if (permission === "granted") new Notification(title, { body: body });
    });
  }

  function alertj(title = "", data, debug = debug || 0) {
    let output = ""; //Object.keys({data})[0]+"\n"
    output += typeof data + "\n"
    if (typeof data == "object") { output += JSON.stringify(data) } else { output += data }
    //    if(debug)alert(output)
    if (debug) popup(title + "<br>" + output.replace(/\n/gmi, "<br>"))
  }

  function popup(text) {
    var ele = document.body.appendChild(document.createElement("span"));
    ele.outerHTML = '<span class="gkscbox" style="all:initial; position: fixed; right:0em; top: ' + popupY + 'em; z-index:2147483647; opacity:1; font-size:90%; font-weight:bold; margin:0px 1px; text-decoration:none !important; text-align:left; padding:1px 6px 1px 6px; border-radius:12px; background-color:#6080ff; color:white; white-space: nowrap;" onclick=\'var a = document.createElement(\"textarea\"); a.value = \"' + text + '\"; document.body.appendChild(a); a.select(); document.execCommand(\"copy\"); a.parentElement.removeChild(a);\'">' + text + '</span>';
    setTimeout(function() {
      $(".gkscbox").remove();
      popupY = 0;
    }, 5000);
    popupY += (2 + ((text + "<br>").match(/<br>/gmi).length));
  }

})();