您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
スレ本文を検索してカタログでスレッド監視しちゃう
当前为
- // ==UserScript==
- // @name futaba_thread_highlighter
- // @namespace https://github.com/himuro-majika
- // @description スレ本文を検索してカタログでスレッド監視しちゃう
- // @include http://*.2chan.net/b/futaba.php?mode=cat*
- // @version 1
- // @require http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js
- // @grant GM_registerMenuCommand
- // @grant GM_getValue
- // @grant GM_setValue
- // ==/UserScript==
- this.$ = this.jQuery = jQuery.noConflict(true);
- (function ($) {
- /*
- ***************************************************************************************
- * 以下jQuery使用可
- */
- console.log(GM_getValue("_futaba_thread_search_words"));
- GM_registerMenuCommand("スレッド検索ワード編集", editWords);
- var userinput; //検索文字列入力値
- function editWords(){
- userinput = prompt("スレ本文に含まれる語句を入力してください。 | を挟むと複数指定できます。正規表現使用可。\n例 : img|dat村|mayちゃん|junくん|dec", GM_getValue("_futaba_thread_search_words") )
- if ( userinput != null ){
- GM_setValue("_futaba_thread_search_words", userinput);
- highlight();
- }
- console.log(GM_getValue("_futaba_thread_search_words"));
- }
- makecontainer();
- function makecontainer() {
- var $pickup_thread_container = $("<div>", {
- id: "futaba_thread_highlighter_highlighted_threads",
- css: {
- "overflow": "hidden"
- }
- });
- $("body > table[align]").before($pickup_thread_container);
- var $container_header = $("<div>", {
- id: "futaba_thread_highlighter_container_header",
- text: "スレッド検索該当スレッド",
- css: {
- backgroundColor: "#F0E0D6",
- fontWeight: "bolder"
- }
- });
- $pickup_thread_container.append($container_header);
- }
- makebutton();
- function makebutton(){
- var $button = $("<span>", {
- id: "futaba_thread_highlighter_searchword",
- text: "[設定]",
- css: {
- cursor: "pointer",
- },
- click: function() {
- editWords();
- }
- });
- $button.hover(function () {
- $(this).css({ backgroundColor:"#EEAA88" });
- }, function () {
- $(this).css({ backgroundColor:"#F0E0D6" });
- });
- $("#futaba_thread_highlighter_container_header").append($button);
- }
- highlight();
- var akahukuloadingflag = false; //赤福更新フラグ
- var akahukuloadstat;
- setInterval(check_akahuku_reloading, "100");
- function check_akahuku_reloading() {
- if ( get_akahuku_reloading_status() == 0 || get_akahuku_reloading_status() == 1 ) {
- akahukuloadstat = true;
- }
- else if ( get_akahuku_reloading_status() == 2 || get_akahuku_reloading_status() == 3 ) {
- if ( akahukuloadstat ) {
- highlight();
- }
- akahukuloadstat = false;
- }
- }
- function get_akahuku_reloading_status() {
- var $acrs = $("#akahuku_catalog_reload_status");
- var $fvw = $("#fvw_mes");
- var relstat;
- if ( $acrs.length ) {
- //akafuku;
- if ( $acrs.text().match(/ロード中/) ) {
- relstat = 0;
- }
- else if ( $acrs.text().match(/更新中/) ) {
- relstat = 1;
- }
- else if ( $acrs.text().match(/完了しました/) ) {
- relstat = 2;
- }
- else {
- relstat = 3;
- }
- }
- if ( $fvw.length ){
- //futakuro;
- if ( $fvw.text().match(/Now Loading/) ) {
- relstat = 0;
- }
- else if ( $fvw.text().match(/更新しました/) ) {
- relstat = 2;
- }
- else {
- relstat = 3;
- }
- }
- return relstat;
- }
- function highlight() {
- var Start = new Date().getTime();//count parsing time
- var words = GM_getValue("_futaba_thread_search_words")
- var re = new RegExp(words, "i");
- if ( words != "" ) {
- $("body > table[align] td small").each(function(){
- if( $(this).text().match(re) ) {
- if ( !$(this).children(".futaba_thread_highlighter_matchedword").length ) {
- $(this).html($(this).html().replace(re, "<span class='futaba_thread_highlighter_matchedword'>" + $(this).text().match(re) + "</span>"));
- }
- $(".futaba_thread_highlighter_matchedword").css("background-color", "#ff0"); //文字の背景色
- $(this).parent().css("background-color", "#FF5C03").addClass("futaba_thread_highlighter_highlighted"); //セルの背景色
- }
- });
- pickup_highlighted();
- }
- console.log('Parsing: '+((new Date()).getTime()-Start) +'msec');//log parsing time
- }
- function pickup_highlighted() {
- if ( $("#futaba_thread_highlighter_highlighted_threads .pickuped").length ) {
- $("#futaba_thread_highlighter_highlighted_threads .pickuped").remove();
- }
- var highlighted = $("body > table .futaba_thread_highlighter_highlighted").clone();
- $("#futaba_thread_highlighter_highlighted_threads").append(highlighted);
- highlighted.each(function(){
- $(this).replaceWith("<div class='pickuped'>" + $(this).html() + "</div>");
- });
- var $pickuped = $(".pickuped");
- $pickuped.css({
- width: "5em",
- //height: "6em",
- margin: "1px",
- overflow: "hidden",
- backgroundColor: "#FF5C03",
- float: "left",
- });
- }
- /*
- ***************************************************************************************
- */
- })(jQuery);