Showing posts with label Userscripts. Show all posts
Showing posts with label Userscripts. Show all posts

December 9, 2010

WikipediaのJimmy Walesさんを見飽きた

ので、ちょっと下のほうに移動してもらうGreasemonkeyのスクリプトを書いた。
以下のページのInstallから。

http://userscripts.org/scripts/show/92125

グリモンのスクリプトはChromeの拡張機能としても使える。インストールの仕方はGreasemonkeyと同じ。アンインストールの仕方はExtentionと同じ。SafariのGreaseKitでも使えます。

ジミー・ウェールズさんが邪魔にならない位置に移動する、はず。

// ==UserScript==
// @name           Move Jimmy's message on Wikipedia
// @namespace      http://satomacoto.blogspot.com/
// @include        http://*.wikipedia.org/*
// @include        http://*.wikitionary.org/*
// @include        http://*.wikinews.org/*
// @include        http://*.wikiquote.org/*
// @include        http://*.wikispecies.org/*
// @include        http://*.wikisource.org/*
// @include        http://*.wikiversity.org/*
// @include        http://*.wikibooks.org/*
// @include        http://*.wikimedia.org/*
// @description    
// ==/UserScript==

(function(){
    var content = document.getElementById("content");
    var siteNotice = document.getElementById("siteNotice");
    content.removeChild(siteNotice);
    content.appendChild(siteNotice); // don't comment out this line, or Jimmy will go away!
})();
20行目を削除したりコメントアウトしたりしたら、ジミーが消えちゃうからさびしくなります。

January 24, 2010

Googleで優先する言語を保存できないのでGreasemokeyでなんとかした その2

相変わらず検索言語の設定が保存できないGoogle先生。MacのときのメインブラウザはSafariで検索は右上のSearchバーを使う。自分でつくっといてアレだが、Google Search Language Selector for Greasemonkey ではいちいち言語を選ぶのめんどくさい。

一発である言語で検索したい。のでまたGreasemonkeyのスクリプトを書いた。

Download

Google Search Language Jumper for Greasemonkey

Description

Googleで

Google en

って調べたら英語で「Google」を検索するページに飛ぶ。

Google ja

って調べたら日本語で「Google」を検索するページに飛ぶ。

January 18, 2010

Chromeの拡張機能が保存されている場所

Windows
C:\Users\(ユーザ)\AppData\Local\Google\Chrome\User Data\Default\Extensions
Mac
~/Library/Application Support/Google/Chrome/Default/Extensions
(ユーザ)はひとによって違います。フォルダについてるわけわかんない文字列はChromeのExtensionsウィンドウでDeveloper modeにするとそれぞれの拡張機能の下に出てくるやつ。

January 16, 2010

MacのChromeの拡張機能が保存されている場所

~/Library/Application Support/Google/Chrome/Default/Extensions/
ひとつのフォルダがひとつの拡張機能に対応している、と思う。

Googleで優先する言語を保存できないのでGreasemokeyでなんとかした



Download

Google Search Language Selector for Greasemonkey

Description

Googleのデフォルトの言語は英語にしている。
でも日本語だけで調べたいときもある。

Setting > Search setting > Search language > Prefer pages written in these language(s):

で Japanese だけ選んでいれば日本語のページだけ検索できた。
のにちょっと前から勝手に

Search English and Japanese pages

になってしまう。
逆にデフォルトの言語を日本語にして

設定 > 検索設定 > 検索言語の設定 > 優先する言語:

で英語だけにチェックして保存しても

英語 と 日本語のページを検索

とかなっちゃう。
なんでだよ!ということでなんとかするためにGreasemonkeyのスクリプトを書いた。

Google Search Language Selector for Greasemonkey

デフォルトでは「すべての言語、英語、日本語」にしてあるけど、スクリプトをちょいと書き換えれば他の言語も単独で調べられるようになる。もうちょい書き換えれば、「英語とフランス語」とかいくつかの言語にも対応できる。

November 21, 2009

LaTeX for BloggerをSafariと新しい編集インターフェイスのために改造する



Bloggerの新しいインターフェイスになってLaTeX for Bloggerが機能しない。(そもそもSafariだと微妙だった。)なのでちょっと書き換えた。正規表現を使ったり。チェックとかはしてない。

ダウンロード

LaTeX for Blogger w/ Undo in the Updated Editor

References

WolverineX02 - LaTeX for Blogger
http://wolverinex02.googlepages.com/emoticonsforblogger2

クリボウの Blogger Tips: Blogger に LaTeX 数式を挿入するユーザースクリプト「LaTeX for Blogger」更新
http://www.kuribo.info/2009/05/blogger-latex-latex-for-blogger.html


コード

// ==/UserScript== 以下を次のように書き換える。

function setlatex(domname) 
{
var editbar = document.getElementById(domname);
  if (editbar) {
    var latexbar = document.createElement('div');
    latexbar.setAttribute("id", "latexbar");
    latexbar.setAttribute("class", "goog-toolbar goog-toolbar-horizontal");

    var buttons = emoticonButton("Latex", "http://wolverinex02.googlepages.com/latex.gif");
    buttons += separator();
    buttons += emoticonButton2("Unlatex", "http://www.codecogs.com/gif.latex?Un%5CLaTeX");

    latexbar.innerHTML = buttons;
    editbar.appendChild(latexbar);
  }
}

function emoticonButton(name, url) {
    var button = " \
    <div class='goog-inline-block goog-toolbar-button' id='htmlbar_undefined' onmousedown=' \
    (function latex_compilator() { \
        var rich_edit = document.getElementById(\"postingComposeBox\"); \
        var rich_body = rich_edit.contentDocument.getElementsByTagName(\"body\"); \
        var contenu = rich_body[0].innerHTML; \
        contenu = contenu.replace(/\\$\\$(.+?)\\$\\$/g,\"<img src=\\\"http://www.codecogs.com/gif.latex?$1\\\" border=0 align=middle />\"); \
        rich_body[0].innerHTML = contenu; } \
    )();'> \
        <img src='" + url + "' alt='" + name + "' border='0'> \
    </div> \
    ";
 return button;
}

function emoticonButton2(name, url) {
    var button = " \
    <div class='goog-inline-block goog-toolbar-button' id='htmlbar_undefined' onmousedown=' \
    (function latex_decompilator() { \
        var rich_edit = document.getElementById(\"postingComposeBox\"); \
        var rich_body = rich_edit.contentDocument.getElementsByTagName(\"body\"); \
        var contentu = rich_body[0].innerHTML; \
        contentu = contentu.replace(/<img(.+?)gif.latex\\\?(.+?)\\\"(.*?)>/g, \"$$$$$2$$$$\"); \
        rich_body[0].innerHTML = contentu; \
    })();'> \
        <img src='" + url + "' alt='" + name + "' border='0'> \
    </div> \
    ";
 return button;
}

function separator() {
  return '<div class="goog-toolbar-separator goog-inline-block">&nbsp;</div>';
}

setlatex("postingComposeToolbar");


以下HTML編集モードに使うときのための自分用メモ

var html_edit = document.getElementById(\"postingHtmlBox\");
var contentu = html_edit.value;
...
html_edit = html_edit.value;
...
setlatex("postingHtmlToolbar");

April 20, 2009

Save a Bookmark on Deliciousで自動的におすすめ/人気タグを入力するGreasemonkeyスクリプト

Download

Delicious Tagger for Greasemonkey

Code

// ==UserScript==
// @name        Delicious Tagger
// @namespace  http://satomacoto.blogspot.com/
// @include     http://delicious.com/save?*
// @description  Adds the populer/recommended tags
// ==/UserScript==

var d = document;

var recos = d.getElementById('save-reco-tags');
var pops = d.getElementById('save-pop-tags');

var tags = '';
if (recos != null) {
  recos = recos.getElementsByClassName('tag-list-tag')
  for (var i = 0; i < recos.length; i++)
    tags += recos[i].innerText + ' ';
}
if (pops != null) {
  pops = pops.getElementsByClassName('tag-list-tag');
  for (var i = 0; i < pops.length; i++)
    tags += pops[i].innerText + ' ';
}

d.getElementById('tags').value = tags;
d.getElementById('tags').focus();

YouTubeで自動的に高画質動画に飛ぶGreasemonkeyスクリプト

// ==UserScript==
// @name        Jump to fmt=18
// @namespace  http://satomacoto.blogspot.com/
// @include     http://*youtube.com/watch*
// @description  YouTubeで自動的に高画質動画(fmt=18)に飛ぶ
// ==/UserScript==

(function() {
var url = location.href;
if(url.indexOf("&fmt")<0){
location.replace(url + "&fmt=18");
}
})();