「Greasemonkey」タグアーカイブ

Googleの検索結果にサムネイルを追加していくユーザースクリプト Part2

google_thumbnail_2

open.thumbshots.org のサムネイルを追加するやつ が使えなくなったりしたので修正したものです。
色々調べてたら似たようなAdd-onsあります。むしろそっちをおすすめします。

動作確認
スクリプトの適当な説明
  • 検索結果の左側に112×82ぐらいの画像を表示
  • AutoPagerizeの2ページ目以降もどんどんサムネ追加
  • Amazonの場合はサムネじゃなくって商品画像を読み込む(一部画像でない)
  • Youtubeの場合は動画サムネを読み込む(一部画像でないかも)
  • ニコニコ動画の場合も動画サムネを読み込む(一部でない) 読み込まなくした
  • Chromeでも一応動く(要Tampermonkey)
  • Safariでも一応動くかもしれない(要NinjaKit)
  • もしかしたらBing検索でも表示される

ダウンロード: google_search_thumbnail.user.js

NinjaKitで管理する場合は Scripts→Add new script→スクリプト貼り付け→Saveで保存 (間違ってるかもしれません)

最近の修正内容とか

右クリック禁止(oncontextmenu)や貼り付け無効(onpaste)を無効にする

油断してるとたまに出てくる「右クリック禁止です」みたいな頭の悪いサイトで禁止された動作を使えるようにします。
oncontextmenu=”return false;” や onpaste=”return false;” のアレです。

以下、貼り付け禁止を無効にするやつです。

なんかいろいろ禁止されてるクソサイトの場合は paste, contextmenu, drop あたり書いとけばいいと思います。

document.addEventListener('paste', event => event.stopImmediatePropagation(), true);
document.addEventListener('contextmenu', event => event.stopImmediatePropagation(), true);
document.addEventListener('drop', event => event.stopImmediatePropagation(), true);

指定したサイトでだけこのスクリプトを有効にしないと右クリックで独自のメニューを出すサイトでは、その右クリックが出なくなるので注意が必要です。

Feedlyで読みたくないエントリーを非表示にするユーザースクリプト

Feedly Proに$99払ったのにあまりプロ感がなくどのあたりが有料なのか分からなくなってきたけど、メインのRSSリーダーとして使ってることに変わりはないので中途半端に作ったやつを修正しました。

例のごとく userscripts.org にありそうだけど自分で作ると修正するとき楽なのでということです。

動作確認

ダウンロード: feedly_filter.user.js

「井上喜久子17才です」っつってんだろ! 17sai.user.js

17sai

声優業界の基礎知識ともいえる井上喜久子さんの年齢がGoogle検索で間違って表示されてしまうのを自動で修正します。
他数名の年齢も同様に修正します。

いや、ノリで作ったジョークスクリプトなので細かく検証してませんよ。
元ネタは “hirataya / 17sai.user.js” です。
動かなかったので今のGoogleに対応させてたら他にも年齢間違って表示されてる箇所があったのでベタ書きで追加してってます。
たぶん、間違いなくGoogle検索が重くなります。要注意です。

※「17歳」ではなく「17才」と表記するのが正しいようなので修正しました。

ダウンロード: 17sai.user.js

Feedly Pro ($99) に申し込んだことだしゴミみたいなユーザースクリプトを作った

\Pro Plan/
feedly_pro

つい最近、Feedlyが月額$5の有料プランを先着5000人だったかで$99払えば生涯使えるというのをやってたので申し込んだのだけど、このプレミアム感のなさに驚愕してゴミみたいなユーザースクリプトを作った。

userscripts.org に絶対ありそうな広告エントリーやら必要なさそうなのを非表示にするやつの簡易版。

好んで使ってたDOMNodeInsertedが廃止予定らしく、MutationObserverというのを使ってるので古いブラウザだと全く動かないしエラーでます。
正直、MutationObserverが使いたかっただけ。

ダウンロード: feedly_filter.user.js

// ==UserScript==
// @name           Feedly Filter
// @description    広告エントリーを非表示にするしか能がない
// @include        http://cloud.feedly.com/*
// @include        https://cloud.feedly.com/*
// ==/UserScript==

(function() {
    var feedly = {
        titles: [
            /^(PR:|AD:|INFO:|【PR】)/i,
            /管理人のブックマーク/,
            /^ダイジェストニュース/,
            /bokete/
        ],
        urls: [
        ],
        observer: new MutationObserver(function(mutations) {
            mutations.forEach(function(mutation) {
                var elm = mutation.addedNodes[0];
                if (elm && elm.nodeName == 'DIV') {
                    feedly.filterEntry(elm);
              }
            });
        }),
        init: function() {
            // this.debug(' init()');
            this.observer.observe(document.body, {childList: true, subtree: true});
            window.addEventListener('beforeunload', this, true);
        },
        handleEvent: function(event) {
            if (event.type == 'beforeunload') {
                // this.debug(' disconnect()');
                this.observer.disconnect();
                window.removeEventListener('beforeunload', this, true);
            }
        },
        debug: function() {
            var i, l = arguments[0];
            for (i = 1; i < arguments.length; i++) {
                if (arguments[i]) l += ', ' + arguments[i];
            }
            unsafeWindow.console.log('[userscript][feedly_filter]' + l);
        },
        filterEntry: function(elm) {
            var a, i, title, read = false;
            if (!elm.className || !elm.className.contains('u0Entry')) return;
            a = elm.getElementsByClassName('title')[0];
            if (a.className == 'title read') {
                read = true;
            }
            title = elm.getAttribute('data-title');
            for (i = 0; i < this.titles.length; i++) {
                if (!this.titles[i].test(title)) continue;
                // this.debug('[hide] ' + title);
                this.hide(elm, read);
                break;
            }
        },
        hide: function(elm, read) {
            var div = elm.getElementsByClassName('condensedTools')[0],
                img, e;

            if (read) {
                elm.style.display = 'none';
                return;
            }
            if (!div) return;
            img = div.getElementsByTagName('img')[1];
            if (img.getAttribute('title') == 'Mark as read and hide') {
                e = document.createEvent('MouseEvents');
                e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
                img.dispatchEvent(e);
            }
        }
    };
    feedly.init();
})();

GmailみたくShift+クリックでチェックボックスをまとめてチェックするGreasemonkeyスクリプト

動作確認
Firefox 15.0 + ユーザースクリプトを実行できるもの
(Greasemonkey or Scriptish or UserScriptLoader.uc.js 0.1.6.1)
Chrome 13.0.782.220

Shift+Clickで複数チェックのあれ便利なのでどこでも使いたいということで作ったGreasemonkeyスクリプト。
userscripts.orgに同じようなのあります。たぶんそっちの方が軽いのでおすすめです。

動作はGmailのと同じにしたかったので、jQueryプラグインのとShift押しっぱなしの動作が若干違うはずです。

<input type=”checkbox”> な要素を全部取得してるのでname属性が違ってもお構いなしです。
また、Ajaxなどで動的にinput要素が追加・削除されてる場合は希に変な感じでチェックされるかもしれません。

ダウンロード: shift_click_multiple_check.user.js

GitHub: shift_click_multiple_check.user.js

最近の更新内容
2012/08/30
64142ee XPathからquerySelectorAllに変更

動作テスト用:

Group1


Group2


Group3


Group4 (Label付き)

// ==UserScript==
// @name         shift+click multiple check
// @description  Shift+Clickで適当にまとめてチェック
// @namespace    http://oflow.me/archives/441
// @include      http://*
// @include      https://*
// @exclude      http://www.google.com/*
// @exclude      http://www.google.co.jp/*
// @exclude      https://www.google.com/*
// @exclude      https://www.google.co.jp/*
// @version      1.1
// @note         XPathからquerySelectorAllに変更
// @note         DOMNodeInsertedの所間違ってた…
// ==UserScript==

// Gmailのチェックボックスの動作をできるだけ再現
// 使いたいサイトでname属性が違うcheckboxの一覧があったのでいい加減にした
// 要素の並び方次第では予想と大幅に変わる可能性がある
// DOMNodeModified, DOMNodeRemovedはもちろん見てないのでおかしくなる可能性がある

(function() {
    var prevCheckbox = null, checkboxes = null, checkboxLength = 0;

    function init(doc, inserted) {
        if (doc.nodeType != 9 && !inserted) return;
        // 追加されたやつにcheckboxあるか確認する
        if (inserted && !doc.querySelector('input[type="checkbox"]')) return;

        var elms = document.querySelectorAll('input[type="checkbox"]');
        checkboxLength = elms.length;
        if (!checkboxLength) return;

        for (var i = 0; i < checkboxLength; i++) {
            if (elms[i].getAttribute('data-multiple-check')) continue;
            elms[i].setAttribute('data-multiple-check', 'true');
            elms[i].addEventListener('click', function(e) {
                if (e.button == 0) multipleCheck(e);
            }, false);
        }
        checkboxes = elms;
   }

    function multipleCheck(e) {
        var self = e.target, checked = self.checked, prev = prevCheckbox;
        prevCheckbox = self;

        if (!prev || !e.shiftKey || self == prev) {
            // シフト押してない, 同じのクリックしてたら止める
            return;
        }

        // 範囲内にあるか確認してチェック状態をどうにか
        for (var i = 0, inRange = 0; i < checkboxLength; i++) {
            var elm = checkboxes[i];
            if (inRange) elm.checked = checked;
            if (elm == prev || elm == self) {
                // 開始 or 終了地点
                elm.checked = checked;
                if (++inRange > 1) break;
            }
        }
    }

    init(document, false);
    // 重いならこれやめるといいかも
    document.addEventListener('DOMNodeInserted', function(e) {
        var node = e.target;
        if (node.nodeType != 1) return;
        // この辺はよく追加されるけど無視していいだろうと
        if (/^(?:a|img|br|script)$/i.test(node.nodeName)) return;
        init(node, true);
    }, false);
})();

Google検索のサムネイルをopen.thumbshots.orgに変えるユーザースクリプト

open.thumbshots.org がまともに画像を表示しなくなったので使えなくなりました。
ということで対応したやつ Part2 の方で。

Googleの検索結果にサムネイルを追加していくユーザースクリプト Part2

過去の修正内容

  • 2012.08.17
    DOMNodeInsertedでdiv#iresを追加するように変わってたので対応
    c49a94fadc
  • 2012.07.11
    httpsじゃない場合もあるので@include増やした
    9df2cc8
  • 2012.06.20
    サムネクリックできるようにリンク追加
    仕様変更に合わせてCSS修正
    6da82c6
  • 2011.11.08
    商品検索などでレビューがあったときサムネイルが表示されてなかったのを修正
  • 2011.11.07
    httpsの場合も有効に
    (画像取得はhttpなので信頼できるサイトの表示はなくなる)
    サイトリンクが付いてる場合のCSSを修正
  • 2011.10.24
    Google Search Number Favicon使用時でもサムネ付くように対応
    AutoPagerize使用時に2ページ目以降サムネ付かなかったのを修正
    NinjaKitのJSLintで怒られないように修正

Google検索でw3support.netだとかうざいサイトがあったら消すやっつけGresemonkeyスクリプト

動作確認
Firefox 6.0.2 + ユーザースクリプトを実行できるもの
(Scriptish 0.1.4 or Greasemonkey 0.9.11 or UserScriptLoader.uc.js 0.1.6.1)

ja.w3support.netだとかアホみたいな翻訳してるサイトがGoogle検索でよく引っかかってうざいから消そう!
というので作ったんですが他にもどんどん消したいのが出てきたんで増やせるようにしたやつです。

※Googleの仕様が変わるともの凄い勢いでエラーでるかもしれません

ダウンロード : google_search_urlfilter.user.js (Ver.1.0.20110916)

うざそうなURL
w3support.net, efreedom.com, vidtaker.com : あほ翻訳
aucfan.com : オークション見ないので
calamel.jp : 何かきもちわるい

// ==UserScript==
// @name           Google search urlfilter
// @namespace      http://oflow.me/archives/231
// @description    urlfilter for Google search result
// @include        http://www.google.co.jp/search*
// @include        http://www.google.co.jp/webhp*
// @include        http://www.google.co.jp/#
// @include        http://www.google.co.jp/#q=*
// @include        http://www.google.co.jp/#hl=*
// @include        http://www.google.com/search*
// @version        1.0.20110916
// ==UserScript==

(function() {
    // うざそうなURL一覧
    var regexpUrls = [
        /^http://[^.]+.w3support./,
        /^http://[^.]+.efreedom.com/,
        /^http://[^.]+.vidtaker.com/,
        /^http://vidtaker.com/,
        /^http://aucfan.com/,
        /^http://calamel.jp/
    ];
    var length = regexpUrls.length;
    function urlfilter(doc) {
        if (doc.nodeType != 1) return;
        var nodes = document.evaluate('.//a[@class="l"]',
                        doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

        for (var i = 0, node; node = nodes.snapshotItem(i); i++) {
            for (var j = 0; j < length; j++) {
                if (regexpUrls[j].test(node.href)) {
                    var li = node.parentNode.parentNode.parentNode.parentNode;
                    li.parentNode.removeChild(li);
                    break;
                }
            }
        }
    }
    urlfilter(document.body);

    window.addEventListener('unload', function() {
        document.body.removeEventListener('DOMNodeInserted', urlfilter, false);
        window.removeEventListener('unload', arguments.callee, false);
    }, false);
})();

Instagramの画像をPCで開いたらI4PCへのリンクを付けるだけのGreasemonkeyスクリプト

PCでInstagramのLikeやコメントが残せる「I4PC」が便利なのですぐそっちに移動できるようにリンク付けます。
※listagramでやったアレとほぼ同じです…。

ダウンロード : instagram_i4pc.user.js
Instagramの仕様変更に伴い終了。


// ==UserScript==
// @name           instagram i4pc
// @description    add instagram photo info, i4pc link
// @version        1.3
// @author         oflow
// @namespace      http://oflow.me/
// @include        http://instagr.am/p/*
// @exclude        https://*
// ==/UserScript==

(function() {
    var css = [
        '.profile-photo { float: none !important; position: absolute; }',
        '.profile-info { float: none !important; margin-left: 60px; }',
        '.profile-info h1 { margin-bottom: 0.3em; }',
        '.profile-info h1 span { font-weight: normal; margin-left: 0.5em; font-size: 90%; }'
    ].join('');

    function getMeta() {
        var meta = document.getElementsByTagName( 'meta' );
        for ( var i = 0, length = meta.length; i < length; i++ ) {
            if ( meta[i].getAttribute( 'property' ) == 'og:description' ) {
                addOgDescription( meta[i].getAttribute( 'content' ) );
                break;
            }
        }
    }

    function addOgDescription( content ) {
        if ( !content ) return;
        var span = document.createElement( 'span' );
        span.appendChild( document.createTextNode( content ) );
        var h1 = document.getElementsByTagName( 'h1' )[0];
        if ( h1 ) {
            h1.appendChild( span );
        }
    }

    function addI4PC() {
        var profileImg = document.getElementsByClassName( 'photo-info' )[0].getElementsByTagName( 'img' )[0];
        if ( !profileImg ) return;
        if ( !//profile_([0-9]+)_/.test( profileImg.src ) ) {
            return;
        }
        var id = RegExp.$1;
        var profileInfo = document.getElementsByClassName( 'profile-info' )[0];
        profileInfo.appendChild( document.createTextNode( ' · ' ) );
        var a = document.createElement( 'a' );
        a.href = 'http://www.i4pc.jp/user/' + id;
        a.appendChild( document.createTextNode( 'I4PC' ) );
        profileInfo.appendChild( a );
    }
    GM_addStyle( css );
    getMeta();
    addI4PC();

} )();