Movatterモバイル変換


[0]ホーム

URL:


はてラボはてな匿名ダイアリー
ようこそ ゲスト さんログインユーザー登録

「regexp」を含む日記RSS

はてなキーワード:regexpとは

次の25件>

2024-09-20

"ちちんこ"って何?https://kinosei.cloudfree.jp/butajisho/index.php?txt=%EF%BC%8A%E3%81%A1%E3%82%93%E3%81%93&regexp=n&nmax=0

→魚ちんこやったわhttps://kotobank.jp/word/%E3%81%A1%E3%81%A1%E3%82%93%E3%81%93-2061563

Permalink |記事への反応(0) | 11:55

このエントリーをはてなブックマークに追加ツイートシェア

2024-06-26

非エンジニアだけどClaude3に増田ミュート作ってもらったよ

これを改善してってお願いした。何書いてあるかわからないけど動いたよ。

https://anond.hatelabo.jp/20240125203115

// ==UserScript==// @name増田ミュート(白塗り版)// @namespace    http://tampermonkey.net/// @version      2024-06-26// @descriptionミューワードを含む最小限の範囲白塗りにする// @authorYou// @match        https://anond.hatelabo.jp/*// @icon         https://www.google.com/s2/favicons?sz=64&domain=hatelabo.jp// @grant        none// ==/UserScript==(function() {    'use strict';const muteWords = [        "弱者男性",        "弱男",        "弱者",        "婚活",        "男",        "女",        "年収",        "下方婚",        "発達障害",        "発達",        "ハッタツ",        "ハッタショ",        "ハッタショ",        "競プロ",        "競技プログラミング",        "AtCoder",    ];    functionwhiteoutElement(element) {        element.style.backgroundColor = 'white';        element.style.color = 'white';        element.style.textShadow = 'none';        element.style.cursor = 'default';        element.style.userSelect = 'none';  //テキスト選択を防止        element.style.borderBottom = '1px dashed #ccc'; // 枠線を追加してテキストがあることを示す        //リンク場合クリック無効化        if (element.tagName === 'A') {            element.style.pointerEvents = 'none';            element.removeAttribute('href');        }        // 子要素にも適用        Array.from(element.children).forEach(child => {            child.style.backgroundColor = 'white';            child.style.color = 'white';            child.style.textShadow = 'none';        });        //ツールチップを追加        element.title = 'この内容にはミューワードが含まれています';    }    function shouldMute(text) {        return muteWords.some(word => {const parts =word.split('');constregex = newRegExp(parts.map(char => `${char}\\s*`).join(''), 'i');            returnregex.test(text);        });    }    function findSmallestMuteableElement(element) {        if (element.nodeType === Node.TEXT_NODE) {            return shouldMute(element.textContent) ? element.parentElement : null;        }        if (element.tagName === 'PRE' || element.tagName === 'CODE') {            return shouldMute(element.textContent) ? element : null;        }        for (let child of element.childNodes) {const result = findSmallestMuteableElement(child);            if (result) return result;        }        return shouldMute(element.textContent) ? element : null;    }    function processElement(element) {const muteableElement = findSmallestMuteableElement(element);        if (muteableElement) {whiteoutElement(muteableElement);        }    }    function processAllElements(root = document.body) {const walker = document.createTreeWalker(root,            NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,            null,false        );        let node;        while (node = walker.nextNode()) {            if (node.nodeType === Node.ELEMENT_NODE) {                processElement(node);            } else if (node.nodeType === Node.TEXT_NODE && node.parentElement) {                processElement(node.parentElement);            }        }    }    function handleClickEvent(event) {        setTimeout(() => {            processAllElements(event.target);        }, 100);    }    // 初回実行    processAllElements();    //クリックイベント監視    document.body.addEventListener('click', handleClickEvent);    //DOM変更の監視constobserver = new MutationObserver(mutations => {        mutations.forEach(mutation => {            if (mutation.type === 'childList') {                mutation.addedNodes.forEach(node => {                    if (node.nodeType === Node.ELEMENT_NODE) {                        processAllElements(node);                    }                });            } else if (mutation.type === 'characterData') {                processElement(mutation.target.parentNode);            }        });    });observer.observe(document.body, { childList:true, subtree:true,characterData:true });})();

Permalink |記事への反応(1) | 16:34

このエントリーをはてなブックマークに追加ツイートシェア

2023-08-04

綺麗なコードって綺麗に書くことじゃないよ

本当にあった話だけど、JavaScriptstrっていう変数テキストが入っていて

その変数に'apple'とか'banana'とかが入ってるかどうかを判別するっていうロジックを作るとき

const re =newRegExp("apple")if(re.test(str))console.log("match")

みたいなサンプルコードを見つけてきて

const re_apple =newRegExp("apple")const re_banana =newRegExp("banana")if ( re_apple.test(str) || re_banana.test(str) )console.log("match")

っていうコードを書く人がおるんよ

別にプログラミング初めて3ヶ月の初心者じゃ無くて20年以上やってるようなベテランだったり

なんならチーフプログラマーとして若手指導してるような人でもこういうレベルの人って割といるわけ

これに対して

正規表現でORを書くべき」

「includeで十分」

かいう指摘ももちろん正しいんだけど

綺麗にコードを書くっていうのは

「これってappleとかbanana以外に増えたりしないの?」

「fruitsかどうかを判別するならその変数を作った方が良くない?」

っていうのを考えて実装するのが綺麗にコードを書くっていうことで

変数名だとか整形とかは大事だけどそういう話じゃ無いんだよね

ちなみに

正規表現でORを書きましょう」

とかをPRレビューコメントしても

「動いてるからいいじゃない」

「綺麗に書いても性能上意味ない」

「言ってることが良く分からない。何が違うのか」

とか言ってくるし

言ってこなくて言われた通りに直しても次もまた同じことしてくるのでマジでレビューって大変だよ

Permalink |記事への反応(3) | 09:03

このエントリーをはてなブックマークに追加ツイートシェア

2023-07-23

素早くブクマされた増田を強調 簡易セルクマ検知ユーザースクリプト

https://b.hatena.ne.jp/site/anond.hatelabo.jp

で動くスクリプトでたとえば投稿10分以内にブクマされページに乗ったら「1user」が「1userセルクマ 1とか5(何分後にブクマされたか)」になる。もしマイナスなら誤判定なので無視して。

時間を置いたセルクマには効かないし普通ファーストブクマカがどれぐらいの頻度で確認してるかしらないけど5分以内や1分以内もポロポロあるのでまあ目安に。

増田URLと一覧の時刻表示差分を取ってます

増田じゃpre記法でも記号が変換されるみたいだから作業

.forEach(div => {

('.entrylist-contents-title> a')

if(diffSec>

とかの

<>

<>

に変えてね

他にも見落としあるかも

誤判定が減るから非公開ファーストブクマを判定できたらいいんだけどね。

// ==UserScript==// @name         hatebu masuda selkmark// @namespacehttp://tampermonkey.net/// @version      0.1// @description特定時間以内にブクマされた増田を強調する// @authorYou// @matchhttps://b.hatena.ne.jp/site/anond.hatelabo.jp*// @grant        none// ==/UserScript==(function() {  'use strict';const threshold = 60 *10 // 何秒以内かconst domain = 'https://anond.hatelabo.jp/'constdateTemplate = '202301020304' // 時分までurl時刻表記constdateTest = newRegExp('\\d{' +dateTemplate.length + '}')  document.querySelectorAll('div.entrylist-contents').forEach(div =&gt; {const masuda = div.querySelector('.entrylist-contents-title&gt; a')constdateStr = masuda.href.substring(domain.length +dateTemplate.length, domain.length)    if (!dateTest.test(dateStr)) {      //キーワードとかconsole.log('not diary',dateStr)      return    }    // newDateできるように変換    //https://amateur-engineer.com/javascript-date-yyyymmddhhmm/const year = parseInt(dateStr.substring(0, 4))const month = parseInt(dateStr.substring(4, 6))const day = parseInt(dateStr.substring(6, 8))const hour = parseInt(dateStr.substring(8,10))constmin = parseInt(dateStr.substring(10,12))constdate = newDate(year, month - 1, day, hour,min)const bukumaDate = newDate(div.querySelector('.entrylist-contents-date').textContent) // 2023/01/23 00:00const diffSec = (bukumaDate -date) /1000 //ms tosec    if (diffSec&gt; threshold) {      return    }    //ブクマuserconstuser = div.querySelector('span.entrylist-contents-users a').lastChilduser.textContent += 'セルクマ ' + (diffSec / 60)    // 古い記事マイナスになる でも2015年ぐらいの記事までかな?新着はセーフ臭い    /*    if(diffSec &lt; 0) {user.textContent += ' 異常差分:' + diffSec    }    */  })})();

Permalink |記事への反応(3) | 12:02

このエントリーをはてなブックマークに追加ツイートシェア

2022-08-15

Webはてブミュー機能作った

勝手に tampermonkey とかに突っ込んで使ってヨロ

スクリプト保守とかするつもりないから、保守とかするつもりのあるパワーの溢れた人が

これ参考とかにしてもっとかっちょよくしたのを greasy fork あたりに公開してくれ

そしたら俺もそれ使う

使い方:

ブラウザの開発環境を開いて、開発コンソールを開く

localStorage.hatebu_ng_word_list に非表示トリガーになる文字列を|区切り登録する。

localStorage.hatebu_ng_word_list = "池田信夫|フェミ|弱者男性|やまもといちろう"

実際のコード

大なり小なり(&gt;)が実体参照で表示されるのはよくわからん。使う人で適宜コードを直してくれ。

// ==UserScript==// @nameはてブの一覧NG記事非表示// @namespacehttp://tampermonkey.net/// @version      0.1// @descriptiontry totakeoverthe world!// @author       masuda// @matchhttps://b.hatena.ne.jp/*// @iconhttps://www.google.com/s2/favicons?sz=64&domain=hatena.ne.jp// @grant        none// ==/UserScript==(function() {'use strict';if (!localStorage.hatebu_ng_word_list) {return;}console.log("はてブの一覧NG記事非表示", localStorage.hatebu_ng_word_list);/* * 例: * localStorage.hatebu_ng_word_list = * "池田信夫|フェミ|弱者男性|やまもといちろう|togetter.com";*/let words = localStorage.hatebu_ng_word_list.split('|').map(w =&gt; newRegExp(w));function entryDelete(els) {els.forEach(el =&gt; {let hit =false;words.forEach(w =&gt; {hit = hit|| w.test(el.textContent);});if (hit) {el.remove();}});}// entrylist-header-main li 1つ目のアイテムentryDelete(document.querySelectorAll('.entrylist-header-main&gt; li'));// 2つ目以降の liアイテムentryDelete(document.querySelectorAll('.entrylist-item&gt; li'));})();

文字正規表現として評価されて、ヒットした記事項目をページから削除する(DOMから要素を削除する)。

際限なくNG登録できるけど、沢山非表示するとつまらない一覧になる

Permalink |記事への反応(0) | 20:19

このエントリーをはてなブックマークに追加ツイートシェア

2022-07-24

anond:20220724140709

Regexp

Permalink |記事への反応(0) | 23:27

このエントリーをはてなブックマークに追加ツイートシェア

2020-05-23

anond:20200521175300

どもども。

「なにか作ってみろ」は有効アドバイス

わたし意見と経歴

わたしは「なにか作ってみろ」系の言説にはまったく同意しません。

わたし自身会社に3ヶ月間みっちり導入教育をしてもらい(COBOL85とPL/I時代がわかる……)、基本的アルゴリズムコントロールブレークマッチング、マスタ-トランザクションソートマージetc.いよいよ時代がわかる……)の演習を(給料をもらいながら)やって、その後もプログラムとつかず離れずでフラフラと生きてきました。

こういう経験新卒カードがあるから有効もので、では1から始めるとしたら……、というときに、プログラミングスクール専門学校)というのは悪くない選択肢ではないかと思います。が、行ったことないので正直わかりません。

実際自分が1から始めるという立場になったら、まったくオロオロして元増田さんのように世のなか(の気にいらないヤツら)に呪詛を吐いて満足するだけだったと思います(当然ながらそれをいくらやってもプログラミングは上達しません)。

「なにか作ってみる」前に動機をはっきりさせる

話をプログラミングだけに限っていえば、一番大事なのはやりかたじゃなくて動機だろうと思います

「なにか作ってみよう」というのは、なにか作ってみようと思ってない人にはまったく心に響かないでしょう。

動機リブンで「なにか作ってみた」人といえば思いだすのは、MikuMikuDance樋口優さん(ミクを簡単に踊らせたい!)とhinadanの若宮正子さん(高齢者にも遊べるゲームが欲しい!)でしょうか。

ただかれらはわたしから見れば(モチベーションを維持しそれを行動に移す)天才で、あんまり参考にならないのも確かです。

作ってみた」は就職に使える経験

あと、元増田さんの動機は「プログラミング生業にしたい」ということなので、野良プログラマでは履歴書上でのアピール力が弱いかも、と思います

ビジネスで使われるアルゴリズムにはそれなりのルールがあります安全な(バグの出にくい)コードの書きかた、「車輪の再発明」はぜず、枯れた(将棋で言えば定跡のような)アルゴリズムを使う、ほかの人に使ってもらえるための工夫(可読性の向上など)、etc.です。

「なにか作ってみよう」を繰りかえしても、そういった作法的なものが身につくかどうか、それは才能に関わってくる問題だと思います。才能だのみの手法を推奨するのは無責任だと思いますね。

また、たとえば「例をコピーして解析する」というのもある意味有効プログラミング学習法ですが、「下手に習うと下手が伝染る」ともいいます。どれがお手本として優れているか、それを見る目はある程度ビジネス用途プログラムに関わっていないと持てないというジレンマがあります

野生のプログラマ就職有効なくらいの力を見せるとしたら、なにかのコミッター(なにする人かよく知りませんが)とかになって「××ならこの人」となったり、プログラミングコンテストで上位の成績を残したりしなければいけないのかもしれません。

どうしたものでしょうね。ブクマカのみなさんの反応を見ると、専門学校でもあまり就職に有利にならない(ホントか?専門学校意味あるのか?)という話ですが、目的就職ならば、一番の近道のような気がします。

じゃあどうすべきか?は他人にはわからない

そこらへんからは、元増田さんがなにをしたいか、あるいは聞いてみたいだけだったのかによります仕事には適性とやる気が大事です。あとは年齢と必要性かな。進路はオーダーメイド以外にはありえないので、提示された案を自分で選んでそれに賭けるしかないのかな、と思います

「なにか作ってみました」の記録

自分がまず作ったもの晒してみろよ

さて、この文章は実はこの一文に反応してのものです。(↑のは前書き)

GWあたりからトシも考えずにRubyの再入門をしていまして、手始めに「首相動静」の整形ツールを作ってみました。

初心者で(Rubyに関しては仕事で使ったことないので)なにか作ってみよう、というとこの程度ですね。

これで就職に有利になるかというと、あんまりそうは思えないなあ。Excelマクロが組めるとかのほうがどこかの事務所に潜りこめそうですよ(でもそれも最近インフレ気味かもしれませんね)。

なにをするツール

朝日新聞首相動静は詳細ですが、改行が入っておらず、大変読みにくいものです。こんな感じです。

首相動静の例(2018年12月11日……話題になったものです)

 【午前】9時31分、自民党本部。33分、同党役員会。10時2分、官邸。5分、閣議。21分、宇宙開発戦略本部。34分、柴山昌彦文部科学相。38分、岩屋毅防衛相。41分、山下貴司法相。11時3分安全保障と防衛力に関する懇談会

 【午後】0時11分、政府与党連絡会議。44分、山口那津男公明党代表。1時27分、日韓議員連盟額賀福志郎会長河村建夫幹事長。2時20分、行政改革推進会議。52分、兼原信官房副長官補、秋葉剛男外務事務次官。3時36分、麻生太郎財務相財務省岡本薫明事務次官太田主計局長。4時7分、太田氏出る。可部生理局長加わる。15分、全員出る。25分、黒川弘務法務事務次官。34分、谷内正太郎国家安全保障局長、北村内閣情報官宮川内閣衛星情報センター所長。41分、谷内、宮川両氏出る。5時3分北村氏出る。10分、東京永田町ザ・キャピトルホテル東急宴会場「鳳凰」で中曽根康弘世界平和研究所設立30周年記念式典に出席し、あいさつ。20分、官邸。6時18分、ガーナのアクフォアド大統領を出迎え。記念撮影。19分、儀仗(ぎじょう)隊による栄誉礼、儀仗。27分、アクフォアド大統領会談。7時12分、署名式、共同記者発表。32分、公邸首相主催の夕食会。8時43分、アクフォアド大統領見送り。9時、ヨルダンのアブドラ国王電話協議

首相動静フォーマット

ただ、これはフォーマットがはっきりしており、

  • 午前と午後はそれぞれ1行になっていて、行頭には【午前】/【午後】という文字列が付いている。
  • 午前と午後の間には空行がある。
  • ひとつひとつイベント時刻表示で始まり句点「。」で終わっている。
  • 時刻は「h時m分」型で、前ゼロはつかない。後にかならず読点「、」が付く。「h時」の部分が前の項目と同じ場合には省略する。
  • 午前いっぱい、午後いっぱいの予定の場合には時刻をつけない(他の首相動静から)。

と、例を見るかぎりキッチリとしたルールに則っているようです。

動機

なので、「これだったら整形できるかも」と思い、再び学びはじめたRubyで整形ツールを作ってみることにしました。

整形ツール
ツール仕様
整形後の例(上記動静を整形)

【午前】

09時31分、自民党本部

09時33分、同党役員会。

10時02分、官邸

10時05分、閣議

10時21分、宇宙開発戦略本部

10時34分、柴山昌彦文部科学相

10時38分、岩屋毅防衛相

10時41分、山下貴司法相

11時03分安全保障と防衛力に関する懇談会

【午後】

00時11分、政府与党連絡会議

00時44分、山口那津男公明党代表

01時27分、日韓議員連盟額賀福志郎会長河村建夫幹事長

02時20分、行政改革推進会議

02時52分、兼原信官房副長官補、秋葉剛男外務事務次官

03時36分、麻生太郎財務相財務省岡本薫明事務次官太田主計局長。

04時07分、太田氏出る。可部生理局長加わる。

04時15分、全員出る。

04時25分、黒川弘務法務事務次官

04時34分、谷内正太郎国家安全保障局長、北村内閣情報官宮川内閣衛星情報センター所長。

04時41分、谷内、宮川両氏出る。

05時03分北村氏出る。

05時10分、東京永田町ザ・キャピトルホテル東急宴会場「鳳凰」で中曽根康弘世界平和研究所設立30周年記念式典に出席し、あいさつ。

05時20分、官邸

06時18分、ガーナのアクフォアド大統領を出迎え。記念撮影

06時19分、儀仗(ぎじょう)隊による栄誉礼、儀仗。

06時27分、アクフォアド大統領会談

07時12分、署名式、共同記者発表。

07時32分、公邸首相主催の夕食会。

08時43分、アクフォアド大統領見送り

09時00分、ヨルダンのアブドラ国王電話協議

う~ん、見やすい!ことないですか?

あと、午後の時刻を24時間制にしたいな、とも思いますが、それは今後の課題(つぎに首相動静話題になったとき)とします。全角数字計算ってどうやるんだろう?

ソース

たぶんRubyistにいろいろ突っこまれると思うけど、こんな感じです。

プログラマ玉石混淆ですが、これは石のほうの例だと思っていただければさいわいです。

はてな記法にはシンタックスハイライトあるけど、増田だとInternal Server Errorになるのではずしました。見にくくてスマソ。

# encoding:utf-8#漢字コンバータライブラリを取りこむ(String漢字変換メソッドを付けてくれる。神)require 'kconv'#正規表現パターン# 時刻をh時m分形式からhh時mm分形式にする#否定後読みを使用する# 時は行頭にあるOneDigitHour = /^((?&lt;![0-1])[0-9]時)/# 分は時のあとにある。このパターンマッチすると、&#92;1が時、&#92;2が分になる。OneDigitMinute = /^([0-9]{1,2}時)(?&lt;![1-5])([0-9]分)/# 分のない、時だけの行のパターン否定先読み使用HourWithoutMinute = /^([0-9]{1,2}時)(?![0-5]?[0-9]分)/# 行頭のh時m分をhh時mm分にするサブ処理(これは関数といっていいの?)def convTopHourMinute2TwoDigits(oneLine)    # 時を変換    oneLine.sub!(OneDigitHour, "0&#92;&#92;1")    # 分を変換    oneLine.sub!(OneDigitMinute, "&#92;&#92;10&#92;&#92;2")    # 分がない場合"00分"を追加    oneLine.sub!(HourWithoutMinute, "&#92;&#92;100分")    #戻り値    oneLineend#入力ファイル名前InputFilename = "首相動静2018年12月11日.txt"# 出力ファイル名前OutputFilename = "首相動静2018年12月11日_編集済.txt"#入力ファイルオープンinFile = File.open(InputFilename, "r")# 出力ファイルオープンoutFile = File.open(OutputFilename, "w")# 時刻パターンシンプルに、h時、m分、h時m分、という3パターンを結合する# 1つのパターンで全部カバーするよりこちらのほうが見やすい。というか、脳の容量の問題で1文に書ききれなかったjikokuPattern = /[0-9]{1,2}時[0-9]{1,2}分、|[0-9]{1,2}時、|[0-9]{1,2}分、/# 午前/午後ampm = /(【午前】|【午後】)/# 午前/午後、あるいは時刻の前で改行するためのパターンkaigyouSign =Regexp.union(ampm, jikokuPattern)#ファイル一括読み込み# 昔は1行ずつ読みこんでました。メインメモリが3MByteとかだったのでcontents = inFile.read.toutf8#入力終了。閉じておきますinFile.close#スコープ関係から、ここでローカル変数に代入# ※Rubyスコープと暗黙の型には泣かされました。これに慣れるのがRubyのコツかしら#  明示的な型宣言はあったほうがいいと思うなあ。エラー出力の理由がわからなかったりするので。hour = ""#デバッグ行はコメント化しています# 時刻パターンチェックのため、コンテンツを出力してみる# p jikokuPattern.match(contents)#エントリを改行サインで行に分けるcontents.gsub!(kaigyouSign, "&#92;n&#92;&#92;&amp;amp;") # "&#92;&#92;&amp;amp;"はマッチした文字列のもの。2重のエスケープ"&#92;&#92;"が必要# 改行チェックのため出力# p contents#入力を行で分割して各行ごとに処理contents.split("&#92;n") do |oneLine|    # 午前/午後を示す開きカッコ"【"があるか    if (oneLine =~ /^【/) then        # そのまま出力        outFile.write(oneLine + "&#92;n")        # p "午前午後:" + oneLinenext    # 空白行は無視スキップする)    elsif (oneLine =~ /^[&#92;s ]*$/) then        # 出力しない        # p " 空白行:&lt;skip&gt;"next    # 行頭に「時」があるか    elsif (oneLine =~ /^[0-9]{1,2}時/) then        # あったら時間表示を抜きだしておく        hour = oneLine.match(/^([0-9]{1,2}時)/)[0]        # p "   時:" + oneLine        outFile.write(convTopHourMinute2TwoDigits(oneLine) + "&#92;n")next    else        # 「時」がなければつけて出力        oneLine = hour + oneLine        # p "普通の行:" + oneLine        outFile.write(convTopHourMinute2TwoDigits(oneLine) + "&#92;n")    endend
感想

手でやったほうが早いね

以上

Permalink |記事への反応(0) | 13:42

このエントリーをはてなブックマークに追加ツイートシェア

2020-03-19

Q:はてなアンテナでうまく更新通知しない

きょうの答え:無視する行にregexp:正規表現でORを意図して間違って二重で「||」があったのですべての行にマッチしてしま無視されてしま

Permalink |記事への反応(0) | 19:20

このエントリーをはてなブックマークに追加ツイートシェア

2016-10-17

vimをtinyでmakeするとエラーが大量に出るんだが

インストール出来てるし起動もできてるから無視していいのかな

clang:warning: argument unused during compilation: '-I .'

clang:warning: argument unused during compilation: '-I proto'

clang:warning: argument unused during compilation: '-U _FORTIFY_SOURCE'

screen.c:1513:17:warning: self-comparisonalways evaluates totrue [-Wtautological-compare]

if (curwin == curwin)

^

screen.c:5676:19:warning: self-comparisonalways evaluates totrue [-Wtautological-compare]

&amp;&amp; Columns == Columns)

regexp.c:3790:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:3790:24:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:3790:24:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:4052:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:4052:24:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:4052:24:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:5276:25:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:5276:25:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:5276:25:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:5337:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

{ if ((rex.reg_match == ((void*)0))) *(&amp;rex.reg_startpos[rp-&gt;rs_no]) = (&amp;rp-&gt;rs_un.sesave)-&gt;se_u.pos; else *(&amp;rex.reg_startp[rp-&gt;rs_no]) = (&amp;rp-&gt;rs_un.sesave)-&gt;se_u.ptr; };

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:5337:24:note: remove extraneous parentheses around the comparison to silence thiswarning

{ if ((rex.reg_match == ((void*)0))) *(&amp;rex.reg_startpos[rp-&gt;rs_no]) = (&amp;rp-&gt;rs_un.sesave)-&gt;se_u.pos; else *(&amp;rex.reg_startp[rp-&gt;rs_no]) = (&amp;rp-&gt;rs_un.sesave)-&gt;se_u.ptr; };

~ ^ ~

regexp.c:5337:24:note: use '=' to turn this equality comparison into an assignment

{ if ((rex.reg_match == ((void*)0))) *(&amp;rex.reg_startpos[rp-&gt;rs_no]) = (&amp;rp-&gt;rs_un.sesave)-&gt;se_u.pos; else *(&amp;rex.reg_startp[rp-&gt;rs_no]) = (&amp;rp-&gt;rs_un.sesave)-&gt;se_u.ptr; };

^~

=

regexp.c:5355:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

{ if ((rex.reg_match == ((void*)0))) *(&amp;rex.reg_endpos[rp-&gt;rs_no]) = (&amp;rp-&gt;rs_un.sesave)-&gt;se_u.pos; else *(&amp;rex.reg_endp[rp-&gt;rs_no]) = (&amp;rp-&gt;rs_un.sesave)-&gt;se_u.ptr; };

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:5355:24:note: remove extraneous parentheses around the comparison to silence thiswarning

{ if ((rex.reg_match == ((void*)0))) *(&amp;rex.reg_endpos[rp-&gt;rs_no]) = (&amp;rp-&gt;rs_un.sesave)-&gt;se_u.pos; else *(&amp;rex.reg_endp[rp-&gt;rs_no]) = (&amp;rp-&gt;rs_un.sesave)-&gt;se_u.ptr; };

~ ^ ~

regexp.c:5355:24:note: use '=' to turn this equality comparison into an assignment

{ if ((rex.reg_match == ((void*)0))) *(&amp;rex.reg_endpos[rp-&gt;rs_no]) = (&amp;rp-&gt;rs_un.sesave)-&gt;se_u.pos; else *(&amp;rex.reg_endp[rp-&gt;rs_no]) = (&amp;rp-&gt;rs_un.sesave)-&gt;se_u.ptr; };

^~

=

regexp.c:5516:22:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:5516:22:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:5516:22:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:6213:21:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:6213:21:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:6213:21:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:6266:25:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:6266:25:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:6266:25:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:6294:25:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:6294:25:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:6294:25:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:6325:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:6325:24:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:6325:24:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:6341:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:6341:24:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:6341:24:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:6363:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:6363:24:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:6363:24:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:7711:25:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:7711:25:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:7711:25:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

regexp.c:7740:23:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

regexp.c:7740:23:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

regexp.c:7740:23:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

In file included fromregexp.c:8043:

./regexp_nfa.c:3995:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:3995:24:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:3995:24:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4014:21:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4014:21:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4014:21:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4036:21:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4036:21:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4036:21:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4055:21:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4055:21:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4055:21:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4086:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4086:24:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4086:24:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4227:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4227:24:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4227:24:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4609:25:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4609:25:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4609:25:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4670:22:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4670:22:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4670:22:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4733:25:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4733:25:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4733:25:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4767:25:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4767:25:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4767:25:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:4954:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:4954:24:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:4954:24:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5106:21:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5106:21:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5106:21:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5120:21:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5120:21:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5120:21:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5144:25:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5144:25:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5144:25:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5231:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5231:24:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5231:24:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5486:25:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5486:25:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5486:25:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5608:21:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5608:21:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5608:21:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5897:23:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5897:23:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5897:23:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:5987:26:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:5987:26:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:5987:26:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:6873:26:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:6873:26:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:6873:26:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:6997:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:6997:24:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:6997:24:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

./regexp_nfa.c:7095:24:warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

if ((rex.reg_match == ((void*)0)))

~~~~~~~~~~~~~~^~~~~~~~~~~~~

./regexp_nfa.c:7095:24:note: remove extraneous parentheses around the comparison to silence thiswarning

if ((rex.reg_match == ((void*)0)))

~ ^ ~

./regexp_nfa.c:7095:24:note: use '=' to turn this equality comparison into an assignment

if ((rex.reg_match == ((void*)0)))

^~

=

Permalink |記事への反応(0) | 12:58

このエントリーをはてなブックマークに追加ツイートシェア

2015-07-27

なろうにかなり女性向けテンプレ作品が増えてきて、鬱陶しくなってきたかタイトルで引っ掛けてある程度フィルタするようにしてみた。

タグで切るか迷ったけど、テンプレをばさっと切るならタイトルのほうかなと。

素人でもこういうのが簡単に作れるようになるんだから最近ブラウザのDeveloperToolとjQueryはすごいと思う。

// ==UserScript==// @name      narou rankng// @namespacehttp://use.i.E.your.homepage/// @version    0.1// @description  entersomething useful// @matchhttp://yomou.syosetu.com/rank/list/*// @copyright  2012+,You// ==/UserScript==(function($){    // ここにNGワード記載する    varngwords=["か[?\?]","令嬢","婚","ない","せん","王子","姫","乙女"];    $("div.rank_h").each(function(){        for (key inngwords){            reg = newRegExp(ngwords[key]);            if( $("[id^=best]",this).html().match(reg) ){                $(this).css("display","none");                $(this).next().css("display","none");            }        }    });})(jQuery);

Permalink |記事への反応(0) | 11:53

このエントリーをはてなブックマークに追加ツイートシェア

2014-10-03

http://anond.hatelabo.jp/20141002222733

Subtest()Dim reAsNewRegExpDimwsAs WorksheetDimbuffAsVariantDim iAsLong 'initializeSetws= ActiveSheetbuff=ws.UsedRangeReDimPreservebuff(1Tows.UsedRange.Rows.Count,1To2) 'setting RegularExpression    re.Pattern=".*\((.*)\).*"    re.IgnoreCase=True    re.Global=True 'Get InformationFor i=LBound(buff,1)ToUBound(buff,1)buff(i,2)= re.Replace(buff(i,1),"$1")buff(i,2)=Replace(buff(i,2),buff(i,1),"")Next 'Pastews.Range(Cells(1,1), Cells(UBound(buff,1),2))=buffEndSub

やや冗長かもしれないけど俺だったらこう書くなあ。(RegExpクラスを利用するための参照設定は忘れずに!)

ループでワークシートのセルアクセスすると行数増えた時に使い物にならなくなるから、シートの値は必ず二次元配列に移して処理してるわ。

久々にプログラミングしたけどやっぱおもしれぇ!

求める答えが同じでもプログラミングする人のソースコードに対する思想の違いが顕著に表れるもんなー。

Permalink |記事への反応(1) | 01:35

このエントリーをはてなブックマークに追加ツイートシェア

2013-06-30

AutoPagerizeを連番URLでも使えるようにする

page-1 page-2 page-3みたいなやつ

autopagerize incrementalでググるとそれっぽいのが出てくる

こんなかんじの記述Autopagerize適当場所に追加したら連番URLでも使えるようになるはず

varpages = getElementsByXPath(this.info.pageElement, htmlDoc);

varurl = this.getNextURL(this.info.nextLink, htmlDoc);

if (this.info.incremental) {

var exp = newRegExp(this.info.incremental.nextMatch,'i');

var _m = this.info.incremental.nextLink;

var step = this.info.incremental.step || 1;

url = this.requestURL.replace(exp,function(m0,m1){

var n = parseInt(m1,10) + step;

return _m.split('#').join(n);

});

}

varnext = getFirstElementByXPath(xpath,doc);

if (next) {

if (this.info.incremental) {

varloc = this.requestURL ||location.href;

var exp = newRegExp(this.info.incremental.nextMatch,'i');

varnextLink = this.info.incremental.nextLink;

var step = this.info.incremental.step || 1;

if (loc.match(exp)) {

returnloc.replace(exp,nextLink.replace("#",parseInt(RegExp.$1)+step));

} else if (!loc.match(exp)) {

returnloc +nextLink.replace("#",step);

}

} else {

returnnext.getAttribute('href') ||next.getAttribute('action') ||next.getAttribute('value');

}

}

連番に適応するSITEINFOはこんなかんじになる

pageelementは普通のsiteinfoと同じ

nextlinkはリンクをたどるわけじゃないので意味ないのだが一応書いておく必要があるので'//a'とでも書いておけばいい

url: '^http://matome\.naver\.jp/odai/'

,incremental: {

nextMatch: 'page=(\\d+)'

,nextLink: 'page=#'

}

,pageElement: '//div[@role="main"]'

,nextLink: '//a'

サンプル

http://matome.naver.jp/odai/2135645268395674701

Permalink |記事への反応(0) | 23:11

このエントリーをはてなブックマークに追加ツイートシェア

2010-11-30

はてブでえがちゃんのエントリーを非表示にするグリモン書いた

すてきな笑顔画像がとてもうざかったので。

// ==UserScript==

// @name deny_ega

// @namespace hogehoge

// @includehttp://b.hatena.ne.jp/*

// ==/UserScript==

var entry_list = document.getElementsByClassName('entry-body');

for (var i = 0; i &lt; entry_list.length; i++) {

var reg =RegExp("http:\/\/blog.livedoor.jp\/ikiradio\/");

vartxt = entry_list[i].getElementsByTagName('blockquote')[0].getAttribute('cite');

if(txt.match(reg)) {

entry_list[i].style.display = 'none';

}

}

Permalink |記事への反応(0) | 10:48

このエントリーをはてなブックマークに追加ツイートシェア

2009-05-31

このブックマークレットはある意味DOSと思われてもしかたないのだが

どうしても、という状況のために。(http://i.hatena.ne.jp/idea/24510、http://i.hatena.ne.jp/idea/24505)

javascript:(function(h,a){if(location.href.match(/(^.+a.hatena.ne.jp).+\/(simple)?/)){var%20s=RegExp.$2,u=RegExp.$1+"/check?url=",x=new%20RegExp("/a\\.[^/]+/"+(s?"go":"map")+"\\?"),y=new%20RegExp("^.+?\\?"+(s?"|\\d{14}$":""),"g"),d=document,l=d.links,i=0,L;while(L=l[i++]){h=L.href;if(h.match(x)&&(!l[i]||l[i++].href.indexOf(u))){a=d.createElement("img");a.src=u+(encodeURIComponent||encodeURI)(h.replace(y,""))+"&robots=1";a.style.display="none";L.parentNode.insertBefore(a,L.nextSibling)}}}})()

全角&を半角&に置換。

imgのsrc=にhttp://a.hatena.ne.jp/checkを呼んでる。表示する必要はないのでdisplay : none。

実行すると、リストされているサイトhttp://a.hatena.ne.jp/checkに渡し、強制的に更新チェックします。よってアンテナのページが複数にわたる場合は各ページで実行する必要がある。

元のブックマークレット

http://www.hatena.ne.jp/tool/bookmarklet#antenna

Permalink |記事への反応(0) | 11:34

このエントリーをはてなブックマークに追加ツイートシェア

2009-05-16

ExciteBlogエラー

MicrosoftVBScript 実行時エラーエラー '800a0030'

DLL 読み込み時のエラーです。: 'regexp'

/zinc/functions/mobile.inc, 行 47

Permalink |記事への反応(0) | 00:43

このエントリーをはてなブックマークに追加ツイートシェア

2009-03-18

公明党都議選重視?

コピーして、test.htaのような拡張子HTAで保存

HTAプログラム

 ↓

<html&gt;

<head&gt;

<style type="text/css"&gt;dt{float:left;clear:left;width:10em;}</style&gt;

<meta content="charset=Shift_JIS"/&gt;

</head&gt;

<body&gt;

<script type="text/javascript"&gt;</p&gt; <p&gt;window.onload = init;</p&gt; <p&gt;varurl = [</p&gt; <p&gt; "<ahref="http://www.senkyo.metro.tokyo.jp/h19sangiin/san_kekka/h19san_hkai.html"&gt;http://www.senkyo.metro.tokyo.jp/h19sangiin/san_kekka/h19san_hkai.html</a&gt;",</p&gt; <p&gt; "<ahref="http://www.senkyo.metro.tokyo.jp/h17shugiin/sokuhou/7kaijyo_s.htm"&gt;http://www.senkyo.metro.tokyo.jp/h17shugiin/sokuhou/7kaijyo_s.htm</a&gt;",</p&gt; <p&gt; "<ahref="http://www.senkyo.metro.tokyo.jp/h17togisen/sokuhou/2kaijyo_s.htm"&gt;http://www.senkyo.metro.tokyo.jp/h17togisen/sokuhou/2kaijyo_s.htm</a&gt;",</p&gt; <p&gt; "<ahref="http://www.senkyo.metro.tokyo.jp/data/h16san_hkai.html"&gt;http://www.senkyo.metro.tokyo.jp/data/h16san_hkai.html</a&gt;",</p&gt; <p&gt; "<ahref="http://www.senkyo.metro.tokyo.jp/data/h15shu_hkai.html"&gt;http://www.senkyo.metro.tokyo.jp/data/h15shu_hkai.html</a&gt;",</p&gt; <p&gt; "<ahref="http://www.senkyo.metro.tokyo.jp/data/data01_01_03.html"&gt;http://www.senkyo.metro.tokyo.jp/data/data01_01_03.html</a&gt;",</p&gt; <p&gt; "<ahref="http://www.senkyo.metro.tokyo.jp/data/data01_02_05.html"&gt;http://www.senkyo.metro.tokyo.jp/data/data01_02_05.html</a&gt;",</p&gt; <p&gt; "<ahref="http://www.senkyo.metro.tokyo.jp/data/data03_04.html"&gt;http://www.senkyo.metro.tokyo.jp/data/data03_04.html</a&gt;",</p&gt; <p&gt; "<ahref="http://www.senkyo.metro.tokyo.jp/data/data01_05_05.html"&gt;http://www.senkyo.metro.tokyo.jp/data/data01_05_05.html</a&gt;"</p&gt; <p&gt;];</p&gt; <p&gt;varbase = "<ahref="http://www.senkyo.metro.tokyo.jp/data/tokuhyo_23ku/"&gt;http://www.senkyo.metro.tokyo.jp/data/tokuhyo_23ku/</a&gt;";</p&gt; <p&gt;var file = ["chiyoda","chuou","minato","shinjyuku","bunkyo",</p&gt; <p&gt; "taitho","sumida","koutho","sinagawa","meguro",</p&gt; <p&gt; "ohta","setagaya","shibuya","nakaono","suginami",</p&gt; <p&gt; "toshima","kita","arakawa","itabashi","nerima",</p&gt; <p&gt; "adachi","katushika","edogawa"];</p&gt; <p&gt;for(var i=0; i<23; i++){</p&gt; <p&gt;url.push(base + file[i] + "\.html");</p&gt; <p&gt;}</p&gt; <p&gt;varid = [</p&gt; <p&gt; "2007参院比", "2005衆院比", "2005都議会", "2004参院比", "2003衆院比",</p&gt; <p&gt; "2001参院比", "2001都議会", "2000衆院比", "1998参院比", "1997都議会"</p&gt; <p&gt;];</p&gt; <p&gt;var ku = [</p&gt; <p&gt; "千代田","中央","港","新宿","文京",</p&gt; <p&gt; "台東","墨田","江東","品川","目黒",</p&gt; <p&gt; "大田","世田谷","渋谷","中野","杉並",</p&gt; <p&gt; "豊島","北","荒川","板橋","練馬",</p&gt; <p&gt; "足立","葛飾","江戸川"</p&gt; <p&gt;];</p&gt; <p&gt;var regexku = newRegExp("(" + ku.join("|") + ")区");</p&gt; <p&gt;var iframe = [];</p&gt; <p&gt;var data = {};</p&gt; <p&gt;var parse = [ function(){</p&gt; <p&gt; var d = iframe[0].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.nodeValue)){</p&gt; <p&gt; for(var j=0, e=td[i]; j<10; j++){</p&gt; <p&gt; e = e.nextSibling;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "0"] = e.firstChild.firstChild.nodeValue.replace(/\.\d+/,"");</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[1].contentWindow.document;</p&gt; <p&gt; var nobr = d.getElementsByTagName("nobr");</p&gt; <p&gt; for(var i=0, l=nobr.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(nobr[i].firstChild.nodeValue)){</p&gt; <p&gt; for(var j=0, e=nobr[i].parentNode; j<4; j++){</p&gt; <p&gt; e = e.nextSibling;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "1"] = e.firstChild.nodeValue;</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[2].contentWindow.document;</p&gt; <p&gt; var nobr = d.getElementsByTagName("nobr");</p&gt; <p&gt; for(var i=0, l=nobr.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(nobr[i].firstChild.nodeValue) &amp;&amp; nobr[i].parentNode.tagName == "SPAN"){</p&gt; <p&gt; for(var j=0, e=nobr[i]; j<6; j++){</p&gt; <p&gt; e = e.parentNode;</p&gt; <p&gt; }</p&gt; <p&gt; vare2 = e.nextSibling.nextSibling.firstChild.childNodes[2].firstChild;</p&gt; <p&gt; var k = 0;</p&gt; <p&gt; data[RegExp.$1 + "2"] = 0;</p&gt; <p&gt; while(e2){</p&gt; <p&gt; if(e2.firstChild.firstChild.nodeValue.indexOf("公明党") != -1){</p&gt; <p&gt; data[RegExp.$1 + "2"] += parseInt(e2.parentNode.nextSibling.childNodes[k+2].firstChild.nodeValue.replace(",",""), 10);</p&gt; <p&gt; }</p&gt; <p&gt;e2 =e2.nextSibling;</p&gt; <p&gt; k++;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "2"] = int2str(data[RegExp.$1 + "2"]);</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[3].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.nodeValue)){</p&gt; <p&gt; for(var j=0, e=td[i]; j<19; j++){</p&gt; <p&gt; e = e.nextSibling;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "3"] = e.firstChild.firstChild.nodeValue.replace(/\.\d+/,"");</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[4].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; var regexku2 = /(大田|世田谷|練馬|足立|江戸川)/;</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.nodeValue)){</p&gt; <p&gt; data[RegExp.$1 + "4"] = td[i].nextSibling.nextSibling.firstChild.nodeValue.replace(/\.\d+/,"");</p&gt; <p&gt;continue;</p&gt; <p&gt; }</p&gt; <p&gt; if(regexku2.test(td[i].firstChild.nodeValue)){</p&gt; <p&gt; data[RegExp.$1 + "4"] = (data[RegExp.$1 + "4"] || 0) </p&gt; <p&gt; + parseInt(td[i].nextSibling.nextSibling.firstChild.nodeValue.replace(",","").replace(/\.\d+/,""));</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; for(var j=0; j<5; j++){</p&gt; <p&gt; data[ku[[10,11,19,20,22][j]]+"4"] = int2str(data[ku[[10,11,19,20,22][j]]+"4"]);</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[5].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.firstChild.nodeValue)){</p&gt; <p&gt; for(var j=0, e=td[i]; j<10; j++){</p&gt; <p&gt; e = e.nextSibling;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "5"] = e.firstChild.firstChild.nodeValue.replace(/\.\d+/,"");</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[6].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.firstChild.nodeValue)){</p&gt; <p&gt; for(var j=0, e=td[i]; j<7; j++){</p&gt; <p&gt; e = e.nextSibling;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "6"] = e.firstChild.firstChild.nodeValue.replace(/\.\d+/,"").replace("-","0");</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[7].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.firstChild.nodeValue)){</p&gt; <p&gt; for(var j=0, e=td[i]; j<9; j++){</p&gt; <p&gt; e = e.nextSibling;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "7"] = e.firstChild.firstChild.nodeValue;</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[8].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.firstChild.nodeValue)){</p&gt; <p&gt; data[RegExp.$1 + "8"] = int2str(td[i].nextSibling.firstChild.firstChild.firstChild.nodeValue);</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(n){ return function(){</p&gt; <p&gt; var d = iframe[n+9].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; data[ku[n]+"9"] = 0;</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if((((td[i].firstChild || 0).firstChild || 0).nodeValue || "").indexOf("公明") == 0){</p&gt; <p&gt; data[ku[n]+"9"] += parseInt(td[i].parentNode.lastChild.firstChild.firstChild.nodeValue.replace(",",""));</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; data[ku[n]+"9"] = int2str(data[ku[n]+"9"]);</p&gt; <p&gt; show();</p&gt; <p&gt;}}];</p&gt; <p&gt;function init(){</p&gt; <p&gt; for(var i=0; i<23; i++){</p&gt; <p&gt; vardl = document.createElement("dl");</p&gt; <p&gt;dl.appendChild(document.createTextNode("\n【" + ku[i] + "区における公明票】\n"));</p&gt; <p&gt; for(var j=0; j<10; j++){</p&gt; <p&gt; vardt = document.createElement("dt");</p&gt; <p&gt; vardd = document.createElement("dd");</p&gt; <p&gt;dt.innerText =id[j];</p&gt; <p&gt;dl.appendChild(dt);</p&gt; <p&gt;dl.appendChild(dd);</p&gt; <p&gt; }</p&gt; <p&gt; document.body.firstChild.appendChild(dl);</p&gt; <p&gt; }</p&gt; <p&gt; for(var i=0; i<32; i++){</p&gt; <p&gt; var e = document.createElement("iframe");</p&gt; <p&gt; iframe[i] = e;</p&gt; <p&gt; e.style.display = "none";</p&gt; <p&gt; if(i<9) var f = parse[i];</p&gt; <p&gt; else var f = parse[9](i-9);</p&gt; <p&gt; e.attachEvent("onload", f);</p&gt; <p&gt; e.src =url[i];</p&gt; <p&gt; document.body.appendChild(e);</p&gt; <p&gt; }</p&gt; <p&gt;}</p&gt; <p&gt;function show(){</p&gt; <p&gt; for(var i=0; i<23; i++){</p&gt; <p&gt; vardl = document.body.firstChild.childNodes[i];</p&gt; <p&gt; for(var j=0; j<10; j++){</p&gt; <p&gt; vardt =dl.childNodes[j*2+1];</p&gt; <p&gt;dt.innerText =id[j] + " " + (data[ku[i]+j] || "");</p&gt; <p&gt;dt.nextSibling.innerText =bar(data[ku[i]+j], j);</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt;}</p&gt; <p&gt;function int2str(num){</p&gt; <p&gt; return newString(num).split("").reverse().join("").replace(/(\d{3})/g,"$1,").split("").reverse().join("");</p&gt; <p&gt;}</p&gt; <p&gt;functionbar(str,flag){</p&gt; <p&gt;str =str || "";</p&gt; <p&gt; if(str == "" ||str.length < 5) return "";</p&gt; <p&gt; var num = parseInt(str.match(/\d+/)) + 1;</p&gt; <p&gt; var arrow = (flag == 2 ||flag == 6 ||flag == 9) ? " ←" : "";</p&gt; <p&gt; var _bar = new Array(num).join("|") + arrow;</p&gt; <p&gt; return _bar;</p&gt; <p&gt;}</p&gt; <p&gt;</script&gt;

</body&gt;

</html&gt;

Permalink |記事への反応(4) | 11:24

このエントリーをはてなブックマークに追加ツイートシェア

2008-12-15

mixi ホーム画面のマイミク一覧をログイン時間順で表示するグリモン

ふと思い立って昼休みに作った。経過時間別に背景色もつきます。

グループ分けとかしてるとうまく動かないかも。

order_home_mymixi.user.js

// ==UserScript==// @name          order_home_mymixi// @namespace     http://anond.hatelabo.jp/// @include       http://mixi.jp/// @include       http://mixi.jp/home.pl// ==/UserScript==(function() {    if (window != window.parent) return;    var homeTds = document.evaluate('//div[@id="mymixiList"]//td', document.body, null, 7, null);    for (var i = 0; i < homeTds.snapshotLength; i++) homeTds.snapshotItem(i).innerHTML = 'loading...';    GM_xmlhttpRequest({        method: 'GET',url: 'http://mixi.jp/list_friend_simple.pl',        onload: function(res) {            var friends = [];            var bgColor = {                '01': '#ffffff',                '02': '#fee7c6',                '03': '#ffd8a7'            };            var div = document.createElement('div');            div.innerHTML = res.responseText;            vartds = document.evaluate('//div[@id="friendList"]//td', div, null, 7, null);            for (var i = 0; i <tds.snapshotLength; i++) {                var td =tds.snapshotItem(i);                var klass = td.getAttribute('class');                if (!klass || klass.search(/^iconState(01|02|03)/) == -1)continue;                friends.push({color: bgColor[RegExp.$1],                    anchor: td.getElementsByTagName('a')[0],name: td.getElementsByTagName('p')[0].innerHTML.replace(/^(.+)\(/, '$1 (')                });            }            for (var i = 0; i < homeTds.snapshotLength; i++) {                var td = homeTds.snapshotItem(i);                td.innerHTML = '';                td.style.background = friends[i].color;                td.appendChild(friends[i].anchor);                var span = document.createElement('span');                span.innerHTML = friends[i].name;                td.appendChild(span);            }        }    });})();

Permalink |記事への反応(0) | 17:44

このエントリーをはてなブックマークに追加ツイートシェア

2008-11-04

http://anond.hatelabo.jp/20081104011946

bookmarkletでおk

javascript:s=prompt('Enterword');alert(s+':'+document.body.textContent.match(newRegExp(s,'g')).length)

Permalink |記事への反応(1) | 02:18

このエントリーをはてなブックマークに追加ツイートシェア

2008-08-03

ニコニコ動画を快適化するvimperator設定まとめ

.

8/27追記

本記事末尾のローカルkey mappingを実現するコードを改良してプラグインにしました。

Vimperatorローカルkey mappingを実現するプラグイン local_mappings.js を書いた。

http://anond.hatelabo.jp/20080826124641


まずnicontroller.jsを入れる。

2008-07-14 - やぬすさんとこの日記

http://d.hatena.ne.jp/janus_wel/20080714

→n秒後/前に移動するkey mappingも忘れずに!

vimperatorrcにこれを書く。

Re: autocmd が分からない - hogehoge

http://d.hatena.ne.jp/teramako/20080731/p1

コードをいじった。

" --- autocmd ---" nicovideo" cでコメント入力、Cでコマンド入力、sでシーク、lでボリューム調整、" pで停止/再生、mでミュートのon/off、vでコメの表示トグル、zでズームjavascript <<EOMliberator.plugins.nicomap =function(){// no argsvar list=[    ["p","nicopause"],    ["m","nicomute"],    ["v","nicomementvisible"],    ["z","nicosize"],    ["s","nicoseek"],  ];//has argsvar list2=[    ["c","nicomment"],    ["C","nicommand"],    ["l","nicovolume"],    ["s","nicoseek"],  ];if(buffer.URL.indexOf("http://www.nicovideo.jp/watch") == 0){for (var j=0; j<list.length; j++){      let i = j;      liberator.mappings.addUserMap([1],[list[i][0]],list[i][1],        function(){          liberator.execute(list[i][1]);},{          rhs:":"+list[i][1]+"<CR>"}      );}for (var j=0; j<list2.length; j++){      let i = j;      liberator.mappings.addUserMap([1],[list2[i][0]],list2[i][1],        function(){  liberator.execute('normal :'+list2[i][1]+'<Space>');},{  rhs:":"+list2[i][1]+"<Space>"}      );}}else{for (var i=0; i<list.length; i++){      liberator.mappings.remove(1,list[i][0]);}for (var i=0; i<list2.length; i++){      liberator.mappings.remove(1,list2[i][0]);}}};liberator.autocommands.add('LocationChange','.*','js liberator.plugins.nicomap()');EOM

フォーカスプレーヤーに奪われないようにするグリモン

2008-08-02 -地獄の猫日記

http://d.hatena.ne.jp/nokturnalmortum/20080802#1217633913

→→これで超快適すぎるニコライフの幕開け!

.

補足

現在マウスカーソル位置でクリックイベント発生するkey mappingを設定できればより快適なんだが・・・。

(「コメントする」ボタンDOMノードが取得できれば、dispatchEventでいけそうだけど)

追記: ちょっと改良してみた。
" ************* localkey mappings ****************javascript <<EOM (function(){function setlocalmap(obj){    var list = obj.list;    var list2 = obj.list2;    var exp = obj.exp;    if(list.constructor != Array || list2.constructor != Array){      echr("invalid argument: array argument required");return;    }    if(exp.constructor !=RegExp){      echr("invalid argument:regex argument required");return;    }    if(exp.test(liberator.buffer.URL)){      for (var j=0; j<list.length; j++){        let i = j;        liberator.mappings.addUserMap([1],[list[i][0]],list[i][1],          function(){            liberator.execute(list[i][1]);          },{            rhs:":"+list[i][1]+"<CR>"          }        );      }      for (var j=0; j<list2.length; j++){        let i = j;        liberator.mappings.addUserMap([1],[list2[i][0]],list2[i][1],          function(){    liberator.execute('normal :'+list2[i][1]+'<Space>');  },{    rhs:":"+list2[i][1]+"<Space>"  }        );      }    } else {      for (var i=0; i<list.length; i++){        liberator.mappings.remove(1,list[i][0]);      }      for (var i=0; i<list2.length; i++){        liberator.mappings.remove(1,list2[i][0]);      }    }}/**  *AddKey Mappings to SpecificWebPages * @param obj :has following properties *  list : commands thattake no args *  list2 : commands thattake args *  exp : target page'sURL (regex) * @see Re: autocmd が分からない - hogehoge * http://d.hatena.ne.jp/teramako/20080731/p1 */liberator.plugins.addLocalUserMap = function(obj){  liberator.plugins[obj.name + "MapSetter"] = function(){    setlocalmap(obj);  }  liberator.autocommands.add(  'LocationChange', '.*', 'js liberator.plugins.' + obj.name + 'MapSetter()'  );};// nicovideo// cでコメント入力、Cでコマンド入力、sでシーク、lでボリューム調整、// pで停止/再生、mでミュートのon/off、vでコメの表示トグル、zでズーム。var nicovideo = {name : 'nico',exp : /^http:\/\/www.nicovideo.jp\/watch/,list : [    ["p","nicopause"],    ["m","nicomute"],    ["v","nicomementvisible"],    ["z","nicosize"],    ["s","nicoseek"],],list2 : [    ["c","nicomment"],    ["C","nicommand"],    ["l","nicovolume"],    ["s","nicoseek"],],};liberator.plugins.addLocalUserMap(nicovideo);})();EOM

Permalink |記事への反応(1) | 20:23

このエントリーをはてなブックマークに追加ツイートシェア

2008-07-22

[greasemonkey]関連エントリーのツリーをたどれるグレモン

結局概要表示機能追加した。unsafeWindow使いまくり大丈夫かいな。

// ==UserScript==// @nameHatenaBookmarkTree Expander// @namespacehttp://anond.hatelabo.jp/// @includehttp://b.hatena.ne.jp/entry/*// ==/UserScript==// <div class="info">//   <ulid="similar_entries" class="bookmarklist">//     <li></li>//   </ul>// </div>// <div class="info">//   <ulid="referred_entries" class="bookmarklist">//     <liid="referred-entry-\d+"></li>//   </ul>// </div>// <div class="info">//   <ulid="relation_diary" class="bookmarklist">//     <liid="diary-{id}-\d+"></li>//   </ul>// </div>(function() {function main() {loadBookmarkCommentViewer();similar.prototype.rootAppend();referred.prototype.rootAppend();}function HBTM(target) {this.target = target;this.targetXPath = "//ul[@id='"+target+"']/li";this.targetRegExp = newRegExp('<ulid="'+target+'"(.|\\s)*?</ul>');}HBTM.prototype = {openIcon:'<img width="15" height="15" class="icon" style="opacity: 0.6"src="http://anond.hatelabo.jp/images/common/open.gif"/>',closeIcon:'<img width="15" height="15" class="icon" style="opacity: 0.6"src="http://anond.hatelabo.jp/images/common/close.gif"/>',loadingIcon:'<img width="13" height="13" class="icon"src="http://anond.hatelabo.jp/images/common/loading.gif"/>',commentIcon: function(url) {return '<img class="hatena-bcomment-view-icon"src="http://r.hatena.ne.jp/images/popup.gif" onclick="iconImageClickHandler(this, \''+url+'\', event);">'},create: function() {this.comment = document.createElement("span");this.comment.innerHTML = this.commentIcon($X("string(descendant::a/@href)", this.node).value());this.open = document.createElement("a");this.open.href = "javascript:void(0)";this.open.innerHTML = this.openIcon;this.close = document.createElement("a");this.close.href = "javascript:void(0)";this.close.innerHTML = this.closeIcon;this.close.style.display = "none";this.loading = document.createElement("span");this.loading.innerHTML = this.loadingIcon;this.loading.style.display = "none";this.node.appendChild(this.comment);this.node.appendChild(document.createTextNode(" "));this.node.appendChild(this.open);this.node.appendChild(this.close);this.node.appendChild(this.loading);this.open.addEventListener("click",bind(this.openAct, this), false);this.close.addEventListener("click",bind(this.closeAct, this), false);},openAct: function() {this.open.style.display = "none";if (this.tree) {this.tree.style.display = "block";this.close.style.display = "inline";} else {this.loading.style.display = "inline";this.load();}},closeAct: function() {if (this.tree) {this.tree.style.display = "none";this.close.style.display = "none";this.open.style.display = "inline";}},load: function() {varurl = $X("string(descendant::a[starts-with(@href, '/entry/')]/@href)", this.node).value();GM_xmlhttpRequest({method: "GET",url: "http://b.hatena.ne.jp"+url,onload:bind(this.loadCallback, this)});},loadCallback: function(result) {var match = result.responseText.match(this.targetRegExp);if (match) {var sandbox = document.createElement("div");sandbox.innerHTML = match[0].replace(this.target,"");this.tree = sandbox.firstChild;} else {this.tree = document.createElement("ul");}this.append();this.loading.style.display = "none";this.close.style.display = "inline";},append: function() {this.tree.style.backgroundColor = "transparent";this.tree.style.listStyleType = "circle";this.node.appendChild(this.tree);$X("li", this.tree).each(function(n) {var a = $X("a",n).node();var c = $X("count(//li/a[@href='"+a.href+"'])").value();if (c > 1) n.parentNode.removeChild(n);});$X("li", this.tree).each(bind(function(node){new this.constructor(node)}, this));},rootAppend: function() {$X(this.targetXPath).each(bind(function(node){new this.constructor(node)}, this));}};function similar(node) {this.node = node;this.create();}similar.prototype = new HBTM("similar_entries");similar.prototype.constructor = similar;function referred(node) {this.node = node;this.create();}referred.prototype = new HBTM("referred_entries");referred.prototype.constructor = referred;function loadBookmarkCommentViewer() {varhead = document.getElementsByTagName("head")[0];varscript = document.createElement("script");script.type = "text/javascript";script.src = "http://b.hatena.ne.jp/js/BookmarkCommentViewerAllInOne.1.2.js";head.appendChild(script);varcss = document.createElement("link");css.rel="stylesheet";css.href="http://d.hatena.ne.jp/css/base.css";css.type="text/css";css.media="all";head.insertBefore(css,head.firstChild);window.addEventListener("load",function(){var BCV = unsafeWindow.BookmarkCommentViewer;BCV.options['screenshot'] = true;var asyncCommnetView = BCV.asyncCommnetView;BCV.asyncCommnetView = function(url, onCompleteCallback) {var div = asyncCommnetView(url, function(){onCompleteCallback.apply(this, arguments);new unsafeWindow.Ten.XHR("http://b.hatena.ne.jp/entry/rss/"+url, {}, function(result) {if (! result.responseText.match(/<description>(.*?)<\/description>/))return;if (!RegExp.$1)return;//var desc = document.createTextNode("desc: "+RegExp.$1);var desc = document.createElement("li");desc.appendChild(document.createTextNode("desc: "+RegExp.$1));div.lastChild.insertBefore(desc,div.lastChild.getElementsByTagName("li")[0]);});});return div;};BCV.asyncCommnetView.origin = asyncCommnetView;}, false);}functionbind(f,o) {return function() {return f.apply(o, arguments)}}function $X(xpath, context) {if (!(this instanceof $X))return new $X(xpath, context);this.xpath =xpath;this.context = context || document;}$X.prototype = {evaluate: function() {var result = document.evaluate(this.xpath, this.context, null, this.type, null);switch (result.resultType) {case XPathResult.STRING_TYPE : return result.stringValue;case XPathResult.NUMBER_TYPE : return result.numberValue;case XPathResult.BOOLEAN_TYPE: return result.booleanValue;case XPathResult.FIRST_ORDERED_NODE_TYPE: return result.singleNodeValue;}return result;},node: function() {this.type = XPathResult.FIRST_ORDERED_NODE_TYPE;return this.evaluate();},value: function() {this.type = XPathResult.ANY_TYPE;return this.evaluate();},each: function(func) {this.type = XPathResult.ORDERED_NODE_SNAPSHOT_TYPE;var result = this.evaluate();for (var i=0; i<result.snapshotLength; i++)func(result.snapshotItem(i));}};main();})();

Permalink |記事への反応(1) | 01:37

このエントリーをはてなブックマークに追加ツイートシェア

2008-04-09

YourFileHost の簡単な FLV 保存方法

YourFileHost で動画再生している時に下の文字をアドレスバーコピペして、Enterキー押すと簡単にflvファイル落とせるね!

javascript:if(document.body.innerHTML.match(/<param\sname=\"movie\"(.*?)%2526cid%253D(.*?)%2526(.*?)%2526cdnkey%253D(.*?)%2526/)){location.href="http://cdn.yourfilehost.com/unit1/flash8/"+RegExp.$2.substr(0,2)+"/"+RegExp.$2+".flv?key="+decodeURIComponent(RegExp.$4)}else{alert("Failed");}

ブックマークURLに登録して再生中にそのブックマーク開くと、同じように落とせるしこっちの方が簡単だね。

ブックマークレットってやつだね。

ま、全部試してないけど、これとかは落とせたね。

http://www.yourfilehost.com/media.php?cat=video&file=one_night_stand.wmv

Permalink |記事への反応(0) | 16:50

このエントリーをはてなブックマークに追加ツイートシェア

2008-03-08

[greasemonkey][greasemonkey][seahorse]はてブのhotentryで、2chコピペブログや「ネタ」を削除す...勝手に改造

firefoxでしか確認していないけれど、URL正規表現XPathで指定できる様にしてみたよ。

// ==UserScript==// @name           filter forHatena::Bookmark// @namespacehttp://anond.hatelabo.jp/// @includehttp://b.hatena.ne.jp/hotentry*// @includehttp://b.hatena.ne.jp/entrylist*// originhttp://anond.hatelabo.jp/20080302214727// ==/UserScript==(function(){var itemxpath = "//div[@class='entry']";function xpathgenURL(url) {return "//div[@class='entry' and descendant::a[starts-with(@href,'"+url+"')]]"}var filters = [// start with '//' thenxpath// moconico douga//{"tag": "div", "name": "entry", "pattern": "nicovideo\.jp"},"//div[@class='entry' and descendant::a[contains(@href,'nicovideo.jp')]]",/*//tag of "2ch"{"tag": "a", "name": "tag", "pattern": "2ch", "parentNum": HatebuTagParentNum},{"tag": "a", "name": "tag", "pattern": "\\*2ch", "parentNum": HatebuTagParentNum},***/// start with 'http' thenurl//2ch blogs  //livedoor//{"tag": "div", "name": "entry",//"pattern": /http:\/\/blog\.livedoor\.jp\/(insidears|dqnplus)\//},"http://blog.livedoor.jp/insidears/","http://blog.livedoor.jp/dqnplus/",//{"tag": "div", "name": "entry",//"pattern": /http:\/\/(guideline|alfalfa|news4vip)\.livedoor\.biz\//},"http://guideline.livedoor.biz/","http://alfalfa.livedoor.biz/","http://news4vip.livedoor.biz/",// typeof /regexp/ is function (@firefox) thenregexp pattern//fc2//{"tag": "div", "name": "entry",//"pattern": /http:\/\/(urasoku|news23vip|waranote|vipvipblogblog|netanabe|res2ch|kanasoku|tenkomo)\.blog\d+\.fc2\.com\//},/http:\/\/(urasoku|news23vip|waranote|vipvipblogblog|netanabe|res2ch|kanasoku|tenkomo)\.blog\d+\.fc2\.com\//,//tag of "neta"//{"tag": "a", "name": "tag", "pattern": "ネタ", "parentNum": HatebuTagParentNum},"//div[@class='entry' and descendant::a[@class='tag' andstring()='ネタ']]",//{"tag": "a", "name": "tag", "pattern": "*ネタ", "parentNum": HatebuTagParentNum},"//div[@class='entry' and descendant::a[@class='tag' andstring()='*ネタ']]",//hatena anonymouse diary//{"tag": "div", "name": "entry", "pattern": /http:\/\/anond\.hatelabo\.jp\//}"http://anond.hatelabo.jp/",];for (var i=0; i<filters.length; i++) {var filter = filters[i];var type = typeof filter;varregexp;varxpath;if (type == "function") {xpath = itemxpath;regexp = filter;} else if (type == "string") {if (filter.match(/^http/)) {xpath = xpathgenURL(filter);} else if (filter.match(/^\/\//)) {xpath = filter;} else {next;}}var removeNodes = document.evaluate(xpath,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for (var j=0; j<removeNodes.snapshotLength; j++) {var node = removeNodes.snapshotItem(j);if (!regexp || node.innerHTML.match(regexp)) {node.parentNode.removeChild(node);}}}})();

ついでに増田版も作ってみたよ。

// ==UserScript==// @name           filter for Hatelabo::AnonymousDiary// @namespacehttp://anond.hatelabo.jp/// @includehttp://anond.hatelabo.jp/// @includehttp://anond.hatelabo.jp/*?page=*// @excludehttp://anond.hatelabo.jp/YourID/*// ==/UserScript==// originhttp://anond.hatelabo.jp/20080302214727(function(){var itemxpath = "//div[@class='section']";function xpathgenURL(url) {return "//div[@class='section' and descendant::a[starts-with(@href,'"+url+"')]]"}var filters = [// start with '//' thenxpath"//div[@class='section' and child::h3[starts-with(string(),'■はてな嫌われ者!')]]",// start with 'http' thenurl"http://anond.hatelabo.jp/",// typeof /regexp/ is function (@firefox) thenregexp pattern/釣り/,];for (var i=0; i<filters.length; i++) {var filter = filters[i];var type = typeof filter;varregexp;varxpath;if (type == "function") {xpath = itemxpath;regexp = filter;} else if (type == "string") {if (filter.match(/^http/)) {xpath = xpathgenURL(filter);} else if (filter.match(/^\/\//)) {xpath = filter;} else {next;}}var removeNodes = document.evaluate(xpath,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for (var j=0; j<removeNodes.snapshotLength; j++) {var node = removeNodes.snapshotItem(j);if (!regexp || node.innerHTML.match(regexp)) {node.parentNode.removeChild(node);}}}})();

Permalink |記事への反応(2) | 20:06

このエントリーをはてなブックマークに追加ツイートシェア

2007-10-09

http://anond.hatelabo.jp/20071009171336

http://anond.hatelabo.jp/20071009142256 の人ですが、ごめん、結構適当書いてました。余計な事してました。ぜんぜん確認してませんでした。という事でバグフィクス版。

javascript:l=location;w=window;u=l.pathname;(function(){wd='/product/';st=u.indexOf(wd);if(st==-1){wd='/ASIN/';st=u.indexOf(wd);}if(st==-1){wd='/dp/';st=u.indexOf(wd);}if(st!=-1){asin=u.substring(st+wd.length,st+10+wd.length);if(prompt('ShortestAmazonURL and thisopen withHatena','http://www.amazon.co.jp/dp/'+asin)){w.open('http://d.hatena.ne.jp/asin/'+asin,'_blank','');}}else{w.alert('noasin info');}}());

ただ、正規表現使えばもっとシンプルになる。って事で同じ動作を書きなおしてみました。

javascript:(function(){if(location.pathname.match(/\/(product|ASIN|dp)\/(.{10})/)){asin=RegExp.$2;if(prompt('ShortestAmazonURL and thisopen withHatena','http://www.amazon.co.jp/dp/'+asin))open('http://d.hatena.ne.jp/asin/'+asin,'_blank')}else{alert('noasin info')}})();

さらに、はてなじゃなくて、アマゾンで開きなおす版も。

javascript:(function(){if(location.pathname.match(/\/(product|ASIN|dp)\/(.{10})/)){asin=RegExp.$2;if(prompt('Jump this shortestAmazonURL','http://www.amazon.co.jp/dp/'+asin))location.href='http://www.amazon.co.jp/dp/'+asin}else{alert('noasin info')}})();

最初はダイアログURLの修正が出来る様に、と思ってましたが、良く考えるとあまり意味なさそうなので止めました。

Permalink |記事への反応(1) | 20:33

このエントリーをはてなブックマークに追加ツイートシェア

2007-07-19

/* Ten */if (typeof(Ten) == 'undefined') {    Ten = {};}Ten.NAME = 'Ten';Ten.VERSION = 0.06;/* Ten.Class */Ten.Class = function(klass,prototype) {    if (klass && klass.initialize) {var c = klass.initialize;    } else if(klass && klass.base) {        var c = function() { return klass.base[0].apply(this, arguments) };    } else {var c = function() {};    }    c.prototype =prototype || {};    c.prototype.constructor = c;    Ten.Class.inherit(c, klass);    if (klass && klass.base) {        for (var i = 0;  i < klass.base.length; i++) {    var parent = klass.base[i];            if (i == 0) {                c.SUPER = parent;                c.prototype.SUPER = parent.prototype;            }            Ten.Class.inherit(c, parent);            Ten.Class.inherit(c.prototype, parent.prototype);        }    }    return c;}Ten.Class.inherit = function(child,parent) {    for (varprop in parent) {        if (typeof(child[prop]) != 'undefined' ||prop == 'initialize')continue;        child[prop] = parent[prop];    }}/*//Basic Ten Classes**//* Ten.JSONP */Ten.JSONP = new Ten.Class({    initialize: function(uri,obj,method) {        if (Ten.JSONP.Callbacks.length) {            setTimeout(function() {new Ten.JSONP(uri,obj,method)}, 500);            return;        }        var del =uri.match(/\?/) ? '&' : '?';uri += del + 'callback=Ten.JSONP.callback';        if (!uri.match(/timestamp=/)) {uri += '&' + encodeURI(new Date());        }        if (obj && method) Ten.JSONP.addCallback(obj,method);        this.script = document.createElement('script');        this.script.src =uri;        this.script.type = 'text/javascript';        document.getElementsByTagName('head')[0].appendChild(this.script);    },    addCallback: function(obj,method) {        Ten.JSONP.Callbacks.push({object: obj, method: method});    },    callback: function(args) {        // alert('callback called');        var cbs = Ten.JSONP.Callbacks;        for (var i = 0; i < cbs.length; i++) {            varcb = cbs[i];cb.object[cb.method].call(cb.object, args);        }        Ten.JSONP.Callbacks = [];    },    MaxBytes: 8000,    Callbacks: []});/* Ten.XHR */Ten.XHR = new Ten.Class({    initialize: function(uri,opts,obj,method) {        if (!uri) return;        this.request = Ten.XHR.getXMLHttpRequest();        this.callback = {object: obj, method: method};        var xhr = this;        var prc = this.processReqChange;        this.request.onreadystatechange = function() {            prc.apply(xhr, arguments);        }        var method = opts.method || 'GET';        this.request.open(method,uri, true);        if (method == 'POST') {            this.request.setRequestHeader('Content-Type',                                          'application/x-www-form-urlencoded');        }        var data = opts.data ? Ten.XHR.makePostData(opts.data) : null;        this.request.send(data);    },    getXMLHttpRequest: function() {        var xhr;        var tryThese = [            function () { return newXMLHttpRequest(); },            function () { return new ActiveXObject('Msxml2.XMLHTTP'); },            function () { return new ActiveXObject('Microsoft.XMLHTTP'); },            function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); },        ];        for (var i = 0; i < tryThese.length; i++) {            var func = tryThese[i];            try {                xhr = func;                return func();            } catch (e) {                //alert(e);            }        }        return xhr;    },    makePostData: function(data) {        var pairs = [];        varregexp = /%20/g;        for (var k in data) {            var v = data[k].toString();            var pair = encodeURIComponent(k).replace(regexp,'+') + '=' +                encodeURIComponent(v).replace(regexp,'+');            pairs.push(pair);        }        return pairs.join('&');    }},{    processReqChange: function() {        var req = this.request;        if (req.readyState == 4) {            if (req.status == 200) {                varcb = this.callback;cb.object[cb.method].call(cb.object, req);            } else {                alert("There was a problem retrieving theXML data:\n" +                      req.statusText);            }        }    }});/* Ten.Observer */Ten.Observer = new Ten.Class({    initialize: function(element,event,obj,method) {        var func = obj;        if (typeof(method) == 'string') {            func = obj[method];        }        this.element = element;        this.event = event;        this.listener = function(event) {            return func.call(obj, new Ten.Event(event || window.event));        }        if (this.element.addEventListener) {            if (this.event.match(/^on(.+)$/)) {                this.event =RegExp.$1;            }            this.element.addEventListener(this.event, this.listener, false);        } else if (this.element.attachEvent) {            this.element.attachEvent(this.event, this.listener);        }    }},{    stop: function() {        if (this.element.removeEventListener) {            this.element.removeEventListener(this.event,this.listener,false);        } else if (this.element.detachEvent) {            this.element.detachEvent(this.event,this.listener);        }    }});/* Ten.Event */Ten.Event = new Ten.Class({    initialize: function(event) {        this.event = event;    },    keyMap: {        8:"backspace", 9:"tab", 13:"enter", 19:"pause", 27:"escape", 32:"space",        33:"pageup", 34:"pagedown", 35:"end", 36:"home", 37:"left", 38:"up",        39:"right", 40:"down", 44:"printscreen", 45:"insert", 46:"delete",        112:"f1", 113:"f2", 114:"f3", 115:"f4", 116:"f5", 117:"f6", 118:"f7",        119:"f8", 120:"f9", 121:"f10", 122:"f11", 123:"f12",        144:"numlock", 145:"scrolllock"    }},{    mousePosition: function() {        if (!this.event.clientX) return;        return Ten.Geometry.getMousePosition(this.event);    },    isKey: function(name) {        var ecode = this.event.keyCode;        if (!ecode) return;        var ename = Ten.Event.keyMap[ecode];        if (!ename) return;        return (ename ==name);    },    targetIsFormElements: function() {        var target = this.event.target;        if (!target) return;        var T = (target.tagName || '').toUpperCase();        return (T == 'INPUT' || T == 'SELECT' || T == 'OPTION' ||                T == 'BUTTON' || T == 'TEXTAREA');    },    stop: function() {        var e = this.event;        if (e.stopPropagation) {            e.stopPropagation();            e.preventDefault();        } else {            e.cancelBubble = true;            e.returnValue = false;        }    }});/* Ten.DOM */Ten.DOM = new Ten.Class({    getElementsByTagAndClassName: function(tagName, className, parent) {        if (typeof(parent) == 'undefined') {            parent = document;        }        var children = parent.getElementsByTagName(tagName);        if (className) {             var elements = [];            for (var i = 0; i < children.length; i++) {                var child = children[i];                var cls = child.className;                if (!cls) {continue;                }                var classNames = cls.split(' ');                for (var j = 0; j < classNames.length; j++) {                    if (classNames[j] == className) {                        elements.push(child);                        break;                    }                }            }            return elements;        } else {            return children;        }    },    removeEmptyTextNodes: function(element) {        var nodes = element.childNodes;        for (var i = 0; i < nodes.length; i++) {            var node = nodes[i];            if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) {                node.parentNode.removeChild(node);            }        }    },    nextElement: function(elem) {        do {            elem = elem.nextSibling;        } while (elem && elem.nodeType != 1);        return elem;    },    prevElement: function(elem) {        do {            elem = elem.previousSibling;        } while (elem && elem.nodeType != 1);        return elem;    },    scrapeText: function(node) {        var rval = [];        (function (node) {            var cn = node.childNodes;            if (cn) {                for (var i = 0; i < cn.length; i++) {                    arguments.callee.call(this, cn[i]);                }            }            var nodeValue = node.nodeValue;            if (typeof(nodeValue) == 'string') {                rval.push(nodeValue);            }        })(node);        return rval.join('');    },    onLoadFunctions: [],    loaded: false,    timer: null,    addEventListener: function(event,func) {        if (event != 'load') return;        Ten.DOM.onLoadFunctions.push(func);        Ten.DOM.checkLoaded();    },    checkLoaded: function() {        var c = Ten.DOM;        if (c.loaded) return true;        if (document && document.getElementsByTagName &&            document.getElementById && document.body) {            if (c.timer) {                clearInterval(c.timer);                c.timer = null;            }            for (var i = 0; i < c.onLoadFunctions.length; i++) {                    c.onLoadFunctions[i]();            }            c.onLoadFunctions = [];            c.loaded = true;        } else {            c.timer = setInterval(c.checkLoaded, 13);        }    }});/* Ten.Style */Ten.Style = new Ten.Class({    applyStyle: function(elem, style) {        for (prop in style) {            elem.style[prop] = style[prop];        }    }});/* Ten.Geometry */Ten.Geometry = new Ten.Class({    initialize: function() {        if (Ten.Geometry._initialized) return;        var func = Ten.Geometry._functions;        var de = document.documentElement;        if (window.innerWidth) {            func.getWindowWidth = function() { return window.innerWidth; }            func.getWindowHeight = function() { return window.innerHeight; }            func.getXScroll = function() { return window.pageXOffset; }            func.getYScroll = function() { return window.pageYOffset; }        } else if (de && de.clientWidth) {            func.getWindowWidth = function() { return de.clientWidth; }            func.getWindowHeight = function() { return de.clientHeight; }            func.getXScroll = function() { return de.scrollLeft; }            func.getYScroll = function() { return de.scrollTop; }        } else if (document.body.clientWidth) {            func.getWindowWidth = function() { return document.body.clientWidth; }            func.getWindowHeight = function() { return document.body.clientHeight; }            func.getXScroll = function() { return document.body.scrollLeft; }            func.getYScroll = function() { return document.body.scrollTop; }        }        Ten.Geometry._initialized = true;    },    _initialized: false,    _functions: {},    getScroll: function() {        if (!Ten.Geometry._initialized) new Ten.Geometry;        return {            x: Ten.Geometry._functions.getXScroll(),            y: Ten.Geometry._functions.getYScroll()        };    },    getMousePosition: function(pos) {        //pos should have clientX, clientY sameas mouse event        if ((navigator.userAgent.indexOf('Safari') > -1) &&            (navigator.userAgent.indexOf('Version/') < 0)) {            return {                x:pos.clientX,                y:pos.clientY            };        } else {            var scroll = Ten.Geometry.getScroll();            return {                x:pos.clientX + scroll.x,                y:pos.clientY + scroll.y            };        }    },    getElementPosition: function(e) {        return {            x: e.offsetLeft,            y: e.offsetTop        };    },    getWindowSize: function() {        if (!Ten.Geometry._initialized) new Ten.Geometry;        return {            w: Ten.Geometry._functions.getWindowWidth(),            h: Ten.Geometry._functions.getWindowHeight()        };    }});/* Ten.Position */Ten.Position = new Ten.Class({    initialize: function(x,y) {        this.x = x;        this.y = y;    },    subtract: function(a,b) {        return new Ten.Position(a.x - b.x, a.y - b.y);    }});/*//require Ten.js**//* Ten.SubWindow */Ten.SubWindow = new Ten.Class({    initialize: function() {        var c = this.constructor;        if (c.singleton && c._cache) {            return c._cache;        }        var div = document.createElement('div');        Ten.Style.applyStyle(div, Ten.SubWindow._baseStyle);        Ten.Style.applyStyle(div, c.style);        this.window = div;        this.addContainerAndCloseButton();        document.body.appendChild(div);        if (c.draggable) {            this._draggable = new Ten.Draggable(div, this.handle);        }        if (c.singleton) c._cache = this;        return this;    },    _baseStyle: {color: '#000',        position: 'absolute',        display: 'none',        zIndex: 2,        left: 0,top: 0,        backgroundColor: '#fff',border: '1px solid #bbb'    },    style: {padding: '2px',        textAlign: 'center',        borderRadius: '6px',        MozBorderRadius: '6px',        width: '100px',        height: '100px'    },    handleStyle: {        position: 'absolute',top: '0px',        left: '0px',        backgroundColor: '#f3f3f3',        borderBottom: '1px solid #bbb',        width: '100%',        height: '30px'    },    containerStyle: {margin: '32px 0 0 0',padding: '0 10px'    },    // closeButton: 'close.gif',    closeButton: 'http://s.hatena.com/images/close.gif',    closeButtonStyle: {        position: 'absolute',top: '8px',        right: '10px',        cursor: 'pointer'    },    _baseScreenStyle: {        position: 'absolute',top: '0px',        left: '0px',        display: 'none',        zIndex: 1,overflow: 'hidden',        width: '100%',        height: '100%'    },    screenStyle: {},    showScreen: true,singleton: true,    draggable: true,    _cache: null},{screen: null,    windowObserver: null,    visible: false,    addContainerAndCloseButton: function() {        varwin = this.window;        var c = this.constructor;        var div = document.createElement('div');win.appendChild(div);        Ten.Style.applyStyle(div, c.containerStyle);        this.container = div;        if (c.handleStyle) {            var handle = document.createElement('div');            Ten.Style.applyStyle(handle, c.handleStyle);win.appendChild(handle);            this.handle = handle;        }        if (c.closeButton) {    var btn = document.createElement('img');            btn.src = c.closeButton;            btn.alt = 'close';            Ten.Style.applyStyle(btn, c.closeButtonStyle);win.appendChild(btn);            new Ten.Observer(btn, 'onclick', this, 'hide');            this.closeButton = btn;        }        if (c.showScreen) {            varscreen = document.createElement('div');            Ten.Style.applyStyle(screen, Ten.SubWindow._baseScreenStyle);            Ten.Style.applyStyle(screen, c.screenStyle);            document.body.appendChild(screen);            this.screen =screen;            new Ten.Observer(screen, 'onclick', this, 'hide');        }    },    show: function(pos) {pos = (pos.x &&pos.y) ?pos : {x:0, y:0};        with (this.window.style) {            display = 'block';            left =pos.x + 'px';top =pos.y + 'px';        }        if (this.screen) {            with (this.screen.style) {                display = 'block';                left = Ten.Geometry.getScroll().x + 'px';top = Ten.Geometry.getScroll().y + 'px';            }        }        this.windowObserver = new Ten.Observer(document.body, 'onkeypress', this, 'handleEscape');        this.visible = true;    },    handleEscape: function(e) {        if (!e.isKey('escape')) return;        this.hide();    },hide: function() {        if (this._draggable) this._draggable.endDrag();        this.window.style.display = 'none';        if (this.screen) this.screen.style.display = 'none';        if (this.windowObserver) this.windowObserver.stop();        this.visible = false;    }});/* Ten.Draggable */Ten.Draggable = new Ten.Class({    initialize: function(element,handle) {        this.element = element;        this.handle = handle || element;        this.startObserver = new Ten.Observer(this.handle, 'onmousedown', this, 'startDrag');        this.handlers = [];    }},{    startDrag: function(e) {        if (e.targetIsFormElements()) return;        this.delta = Ten.Position.subtract(            e.mousePosition(),            Ten.Geometry.getElementPosition(this.element)        );        this.handlers = [            new Ten.Observer(document, 'onmousemove', this, 'drag'),            new Ten.Observer(document, 'onmouseup', this, 'endDrag'),            new Ten.Observer(this.element, 'onlosecapture', this, 'endDrag')        ];        e.stop();    },    drag: function(e) {        varpos = Ten.Position.subtract(e.mousePosition(), this.delta);        Ten.Style.applyStyle(this.element, {            left:pos.x + 'px',top:pos.y + 'px'        });        e.stop();    },    endDrag: function(e) {        for (var i = 0; i < this.handlers.length; i++) {            this.handlers[i].stop();        }        if(e) e.stop();    }});/*Hatena */if (typeof(Hatena) == 'undefined') {Hatena = {};}/*Hatena.User */Hatena.User = new Ten.Class({    initialize: function(name) {        this.name =name;    },    getProfileIcon: function(name) {        if (!name)name = 'user';        var pre =name.match(/^[\w-]{2}/)[0];        var img = document.createElement('img');        img.src = 'http://www.hatena.ne.jp/users/' + pre + '/' +name + '/profile_s.gif';        img.alt =name;        img.setAttribute('class', 'profile-icon');        img.setAttribute('width','16px');        img.setAttribute('height','16px');        with (img.style) {margin = '0 3px';border = 'none';            verticalAlign = 'middle';        }        return img;    }}, {    profileIcon: function() {        returnHatena.User.getProfileIcon(this.name);    }});/*Hatena.Star */if (typeof(Hatena.Star) == 'undefined') {Hatena.Star = {};}/*//Hatena.Star.* classes //**/if (window.location && window.location.host.match(/hatena\.com/)) {Hatena.Star.BaseURL = 'http://s.hatena.com/';} else {Hatena.Star.BaseURL = 'http://s.hatena.ne.jp/';}Hatena.Star.Token = null;/*Hatena.Star.User */Hatena.Star.User = new Ten.Class({base:[Hatena.User],    initialize: function(name) {        if (Hatena.Star.User._cache[name]) {            returnHatena.Star.User._cache[name];        } else {            this.name =name;Hatena.Star.User._cache[name] = this;            return this;        }    },    _cache: {}},{    userPage: function() {        returnHatena.Star.BaseURL + this.name + '/';    }});/*Hatena.Star.Entry */Hatena.Star.Entry = new Ten.Class({    initialize: function(e) {        this.entry = e;        this.uri = e.uri;        this.title = e.title;        this.star_container = e.star_container;        this.comment_container = e.comment_container;        this.stars = [];        this.comments = [];    },    maxStarCount: 11},{    flushStars: function() {        this.stars = [];        this.star_container.innerHTML = '';    },    bindStarEntry: function(se) {        this.starEntry =se;        for (var i = 0; i <se.stars.length; i++) {            if (typeof(se.stars[i]) == 'number') {                this.stars.push(newHatena.Star.InnerCount(se.stars[i],this));            } else {                this.stars.push(newHatena.Star.Star(se.stars[i]));            }        }        if (se.comments && !this.comments.length) {            for (var i = 0; i <se.comments.length; i++) {                this.comments.push(newHatena.Star.Comment(se.comments[i]));            }        }        this.can_comment =se.can_comment;    },    setCanComment: function(v) {        this.can_comment = v;    },    showButtons: function() {        this.addAddButton();        this.addCommentButton();    },    addAddButton: function() {        if (this.star_container) {            this.addButton = newHatena.Star.AddButton(this);            this.star_container.appendChild(this.addButton);        }    },    addCommentButton: function() {        if (this.comment_container) {            this.commentButton = newHatena.Star.CommentButton(this);            this.comment_container.appendChild(this.commentButton.img);        }    },    showStars: function() {        var klass = this.constructor;        // if (this.stars.length > klass.maxStarCount) {        //     varic = newHatena.Star.InnerCount(this.stars.slice(1,this.stars.length));        //     this.star_container.appendChild(this.stars[0]);        //     this.star_container.appendChild(ic);        //     this.star_container.appendChild(this.stars[this.stars.length - 1]);        // } else {        for (var i = 0; i < this.stars.length; i++) {            this.star_container.appendChild(this.stars[i]);        }    },    showCommentButton: function() {        if (this.can_comment) {            this.commentButton.show();            if (this.comments.length) this.commentButton.activate();        } else {            // this.commentButton.hide();        }    },    addStar: function(star) {        this.stars.push(star);        this.star_container.appendChild(star);    },    addComment: function(com) {        if (!this.comments) this.comments = [];        if (this.comments.length == 0) {            this.commentButton.activate();        }        this.comments.push(com);    },    showCommentCount: function() {        this.comment_container.innerHTML += this.comments.length;    }});/*Hatena.Star.Button */Hatena.Star.Button = new Ten.Class({    createButton: function(args) {        var img = document.createElement('img');        img.src = args.src;        img.alt = img.title = args.alt;        with (img.style) {    cursor = 'pointer';margin = '0 3px';padding = '0';border = 'none';            verticalAlign = 'middle';        }        return img;    }});/*Hatena.Star.AddButton */Hatena.Star.AddButton = new Ten.Class({base: ['Hatena.Star.Button'],    initialize: function(entry) {        this.entry = entry;        this.lastPosition = null;        var img =Hatena.Star.Button.createButton({src:Hatena.Star.AddButton.ImgSrc,            alt: 'Add Star'        });        this.observer = new Ten.Observer(img,'onclick',this,'addStar');        this.img = img;        return img;    },    ImgSrc:Hatena.Star.BaseURL + 'images/add.gif'},{    addStar: function(e) {        this.lastPosition = e.mousePosition();        varuri =Hatena.Star.BaseURL + 'star.add.json?uri=' + encodeURIComponent(this.entry.uri) +            '&title=' + encodeURIComponent(this.entry.title);        if (Hatena.Star.Token) {uri += '&token=' +Hatena.Star.Token;        }        new Ten.JSONP(uri, this, 'receiveResult');    },    receiveResult: function(args) {        varname = args ? args.name : null;        if (name) {            this.entry.addStar(newHatena.Star.Star({name:name}));            //alert('Succeeded in Adding Star ' + args);        } else if (args.errors) {            varpos = this.lastPosition;pos.x -= 10;pos.y += 25;            var scroll = Ten.Geometry.getScroll();            var scr = newHatena.Star.AlertScreen();            var alert = args.errors[0];            scr.showAlert(alert,pos);        }    }});/*Hatena.Star.CommentButton */Hatena.Star.CommentButton = new Ten.Class({base: ['Hatena.Star.Button'],    initialize: function(entry) {        this.entry = entry;        this.lastPosition = null;        var img =Hatena.Star.Button.createButton({src:Hatena.Star.CommentButton.ImgSrc,            alt: 'Comments'        });        img.style.display = 'none';        this.observer = new Ten.Observer(img,'onclick',this,'showComments');        this.img = img;    },    ImgSrc:Hatena.Star.BaseURL + 'images/comment.gif',    ImgSrcActive:Hatena.Star.BaseURL + 'images/comment_active.gif'},{    showComments: function(e) {        if (!this.screen) this.screen = newHatena.Star.CommentScreen();        this.screen.bindEntry(this.entry);        varpos = e.mousePosition();pos.y += 25;        this.screen.showComments(this.entry,pos);    },hide: function() {        this.img.style.display = 'none';    },    show: function() {        this.img.style.display = 'inline';    },    activate: function() {        this.show();        this.img.src =Hatena.Star.CommentButton.ImgSrcActive;    }});/*Hatena.Star.Star */Hatena.Star.Star = new Ten.Class({    initialize: function(args) {        if (args.img) {            this.img = args.img;            this.name = this.img.getAttribute('alt');        } else {            this.name = args.name;            var img = document.createElement('img');            img.src =Hatena.Star.Star.ImgSrc;            img.alt = this.name;            with (img.style) {padding = '0';border = 'none';            }            this.img = img;        }new Ten.Observer(this.img,'onmouseover',this,'showName');new Ten.Observer(this.img,'onmouseout',this,'hideName');if (this.name) {            this.user = newHatena.Star.User(this.name);            this.img.style.cursor = 'pointer';            new Ten.Observer(this.img,'onclick',this,'goToUserPage');        }        if (args.count && args.count > 1) {            var c = document.createElement('span');            c.setAttribute('class', 'hatena-star-inner-count');            Ten.Style.applyStyle(c,Hatena.Star.InnerCount.style);            c.innerHTML = args.count;            var s = document.createElement('span');            s.appendChild(img);            s.appendChild(c);            return s;        } else {            return this.img;        }    },    ImgSrc:Hatena.Star.BaseURL + 'images/star.gif'},{    showName: function(e) {        if (!this.screen) this.screen = newHatena.Star.NameScreen();        varpos = e.mousePosition();pos.x += 10;pos.y += 25;        this.screen.showName(this.name,pos);    },    hideName: function() {        if (!this.screen) return;        this.screen.hide();    },    goToUserPage: function() {        window.location = this.user.userPage();    }});/*Hatena.Star.InnerCount */Hatena.Star.InnerCount = new Ten.Class({    initialize: function(count, e) {        this.count = count;        this.entry = e;        var c = document.createElement('span');        c.setAttribute('class', 'hatena-star-inner-count');        Ten.Style.applyStyle(c,Hatena.Star.InnerCount.style);        c.style.cursor = 'pointer';        c.innerHTML = count;        new Ten.Observer(c,'onclick',this,'showInnerStars');        this.container = c;        return c;    },    style: {color: '#f4b128',        fontWeight: 'bold',        fontSize: '80%',        fontFamily: '"arial", sans-serif',margin: '0 2px'    }},{    showInnerStars: function() {        varurl =Hatena.Star.BaseURL + 'entry.json?uri=' +        encodeURIComponent(this.entry.uri);        new Ten.JSONP(url, this, 'receiveStarEntry');    },    receiveStarEntry: function(res) {        varse = res.entries[0];        var e = this.entry;        if (encodeURIComponent(se.uri) != encodeURIComponent(e.uri)) return;        e.flushStars();        e.bindStarEntry(se);        e.addAddButton();        e.showStars();    }});/*Hatena.Star.Comment */Hatena.Star.Comment = new Ten.Class({    initialize: function(args) {        this.name = args.name;        this.body = args.body;    }},{    asElement: function() {        var div = document.createElement('div');        with (div.style) {margin = '0px 0';padding = '5px 0';            borderBottom = '1px solid #ddd';        }        varico =Hatena.User.getProfileIcon(this.name);        div.appendChild(ico);        var span = document.createElement('span');        with(span.style) {            fontSize = '90%';        }        span.innerHTML = this.body;        div.appendChild(span);        return div;    }});/*Hatena.Star.NameScreen */Hatena.Star.NameScreen = new Ten.Class({base: [Ten.SubWindow],    style: {padding: '2px',        textAlign: 'center'    },    containerStyle: {margin: 0,padding: 0    },    handleStyle: null,    showScreen: false,    closeButton: null,    draggable: false},{    showName: function(name,pos) {        this.container.innerHTML = '';        this.container.appendChild(Hatena.User.getProfileIcon(name));        this.container.appendChild(document.createTextNode(name));        this.show(pos);    }});/*Hatena.Star.AlertScreen */Hatena.Star.AlertScreen = new Ten.Class({base: [Ten.SubWindow],    style: {padding: '2px',        textAlign: 'center',        borderRadius: '6px',        MozBorderRadius: '6px',        width: '240px',        height: '120px'    },    handleStyle: {        position: 'absolute',top: '0px',        left: '0px',        backgroundColor: '#f3f3f3',        borderBottom: '1px solid #bbb',        width: '100%',        height: '30px',        borderRadius: '6px 6px 0 0',        MozBorderRadius: '6px 6px 0 0'    }},{    showAlert: function(msg,pos) {        this.container.innerHTML = msg;        varwin = Ten.Geometry.getWindowSize();        var scr = Ten.Geometry.getScroll();        var w = parseInt(this.constructor.style.width) + 20;        if (pos.x + w > scr.x +win.w)pos.x =win.w + scr.x - w;        this.show(pos);    }});/*Hatena.Star.CommentScreen */Hatena.Star.CommentScreen = new Ten.Class({base: [Ten.SubWindow],    initialize: function() {        var self = this.constructor.SUPER.call(this);        if (!self.commentsContainer) self.addCommentsContainer();        return self;    },    style: {        width: '280px',        height: '280px',        overflowY: 'auto',padding: '2px',        textAlign: 'center',        borderRadius: '6px',        MozBorderRadius: '6px'    },    handleStyle: {        position: 'absolute',top: '0px',        left: '0px',        backgroundColor: '#f3f3f3',        borderBottom: '1px solid #bbb',        width: '100%',        height: '30px',        borderRadius: '6px 6px 0 0',        MozBorderRadius: '6px 6px 0 0'    },    containerStyle: {margin: '32px 0 0 0',        textAlign: 'left',padding: '0 10px'    },    getLoadImage: function() {        var img = document.createElement('img');        img.src =Hatena.Star.BaseURL + 'images/load.gif';        img.setAttribute('alt', 'Loading');        with (img.style) {            verticalAlign = 'middle';margin = '0 2px';        }        return img;    }},{    addCommentsContainer: function() {        var div = document.createElement('div');        with (div.style) {            marginTop = '-3px';        }        this.container.appendChild(div);        this.commentsContainer = div;    },    showComments: function(e,pos) {        var comments = e.comments;        if (!comments) comments = [];        this.commentsContainer.innerHTML = '';        for (var i=0; i<comments.length; i++) {            this.commentsContainer.appendChild(comments[i].asElement());        }        if (e.starEntry && !e.can_comment) {            this.hideCommentForm();        } else {            this.addCommentForm();        }        varwin = Ten.Geometry.getWindowSize();        var scr = Ten.Geometry.getScroll();        var w = parseInt(this.constructor.style.width) + 20;        if (pos.x + w > scr.x +win.w)pos.x =win.w + scr.x - w;        this.show(pos);    },    bindEntry: function(e) {        this.entry = e;    },    sendComment: function(e) {        if (!e.isKey('enter')) return;        varbody = this.commentInput.value;        if (!body) return;        this.commentInput.disabled = 'true';        this.showLoadImage();        varurl =Hatena.Star.BaseURL + 'comment.add.json?body=' + encodeURIComponent(body) +            '&uri=' + encodeURIComponent(this.entry.uri) +            '&title=' + encodeURIComponent(this.entry.title);        new Ten.JSONP(url, this, 'receiveResult');    },    receiveResult: function(args) {        if (!args.name || !args.body) return;        this.commentInput.value = '';         this.commentInput.disabled = '';        this.hideLoadImage();        var com = newHatena.Star.Comment(args);        this.entry.addComment(com);        this.commentsContainer.appendChild(com.asElement());    },    showLoadImage: function() {        if (!this.loadImage) return;         this.loadImage.style.display = 'inline';    },    hideLoadImage: function() {        if (!this.loadImage) return;         this.loadImage.style.display = 'none';    },    hideCommentForm: function() {        if (!this.commentForm) return;        this.commentForm.style.display = 'none';    },    addCommentForm: function() {        if (this.commentForm) {            this.commentForm.style.display = 'block';            return;        }        var form = document.createElement('div');        this.container.appendChild(form);        this.commentForm = form;        with (form.style) {margin = '0px 0';padding = '5px 0';            // borderTop = '1px solid #ddd';        }        //if (Hatena.Visitor) {        //    form.appendChild(Hatena.Visitor.profileIcon());        //} else {        //    form.appendChild(Hatena.User.getProfileIcon());        //}        var input = document.createElement('input');        input.type = 'text';        with (input.style) {            width = '215px';border = '1px solid #bbb';padding = '3px';        }        form.appendChild(input);        this.commentInput = input;        var img = this.constructor.getLoadImage();        this.loadImage = img;        this.hideLoadImage();        form.appendChild(img);        new Ten.Observer(input,'onkeypress',this,'sendComment');    }});/*Hatena.Star.EntryLoader */Hatena.Star.EntryLoader = new Ten.Class({    initialize: function() {        var entries =Hatena.Star.EntryLoader.loadEntries();        this.entries = [];        for (var i = 0; i < entries.length; i++) {            var e = newHatena.Star.Entry(entries[i]);            e.showButtons();            this.entries.push(e);        }        this.getStarEntries();    },    createStarContainer: function() {        varsc = document.createElement('span');sc.setAttribute('class', 'hatena-star-star-container');sc.style.marginLeft = '1px';        returnsc;    },    createCommentContainer: function() {        varcc = document.createElement('span');cc.setAttribute('class', 'hatena-star-comment-container');cc.style.marginLeft = '1px';        returncc;    },    scrapeTitle: function(node) {        var rval = [];        (function (node) {            if (node.tagName == 'SPAN' &&                (node.className == 'sanchor' ||                 node.className == 'timestamp')) {                     return;            } else if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) {                return;            }            var cn = node.childNodes;            if (cn) {                for (var i = 0; i < cn.length; i++) {                    arguments.callee.call(this, cn[i]);                }            }            var nodeValue = node.nodeValue;            if (typeof(nodeValue) == 'string') {                rval.push(nodeValue);            }        })(node);        return rval.join('');    },    headerTagAndClassName: ['h3',null],    getHeaders: function() {        var t =Hatena.Star.EntryLoader.headerTagAndClassName;        return Ten.DOM.getElementsByTagAndClassName(t[0],t[1],document);    },    loadEntries: function() {        var entries = [];        //var headers = document.getElementsByTagName('h3');        var c =Hatena.Star.EntryLoader;        var headers = c.getHeaders();        for (var i = 0; i < headers.length; i++) {            var header = headers[i];            var a = header.getElementsByTagName('a')[0];            if (!a)continue;            varuri = a.href;            var title = '';            // Ten.DOM.removeEmptyTextNodes(header);            var cns = header.childNodes;            title = c.scrapeTitle(header);            varcc = c.createCommentContainer();            header.appendChild(cc);            varsc = c.createStarContainer();            header.appendChild(sc);            entries.push({uri:uri,                title: title,                star_container:sc,                comment_container:cc            });        }        return entries;    }},{    getStarEntries: function() {        varurl =Hatena.Star.BaseURL + 'entries.json?';        for (var i = 0; i < this.entries.length; i++) {            if (url.length > Ten.JSONP.MaxBytes) {                new Ten.JSONP(url, this, 'receiveStarEntries');url =Hatena.Star.BaseURL + 'entries.json?';            }url += 'uri=' + encodeURIComponent(this.entries[i].uri) + '&';        }        new Ten.JSONP(url, this, 'receiveStarEntries');    },    receiveStarEntries: function(res) {        var entries = res.entries;        if (!entries) entries = [];        for (var i = 0; i < this.entries.length; i++) {            var e = this.entries[i];            for (var j = 0; j < entries.length; j++) {                varse = entries[j];                if (!se.uri)continue;                if (encodeURIComponent(se.uri) == encodeURIComponent(e.uri)) {                    e.bindStarEntry(se);                    entries.splice(j,1);                    break;                }            }            if (typeof(e.can_comment) == 'undefined') {                e.setCanComment(res.can_comment);            }            e.showStars();            e.showCommentButton();        }    }});/*Hatena.Star.WindowObserver */Hatena.Star.WindowObserver = new Ten.Class({    initialize: funct

Permalink |記事への反応(1) | 17:30

このエントリーをはてなブックマークに追加ツイートシェア

2007-05-22

こんな感じかい?

http://anond.hatelabo.jp/20070522023230

<html><head><title>Test</title><script>    dayString =new Array('<fontcolor="#ff0000">日</font>','月','火','水','木','金','<fontcolor="#0000ff">土</font>');function init(){        h1s = document.getElementsByTagName("h1");for(var i=0; i < h1s.length; i++){varh1 = h1s[i];if (h1.innerHTML.match(/([0-9]+)年([0-9]+)月([0-9]+)日/)){var yy =RegExp.$1;varmm =RegExp.$2;vardd =RegExp.$3;var day =new Date(yy,mm-1,dd).getDay();h1.innerHTML = yy+"年"+mm+"月"+dd+"日("+dayString[day]+")";}}}</script></head><bodyonload="init()"><h1>2007年05月10日</h1><h1>2007年05月18日</h1><h1>2007年05月19日</h1><h1>2007年05月20日</h1></body>

素人なのでよくわからないぜ。

追記:バグっていたので直しました。ごめん。 >http://anond.hatelabo.jp/20070522034339

Permalink |記事への反応(1) | 03:31

このエントリーをはてなブックマークに追加ツイートシェア

次の25件>
ログインユーザー登録
ようこそ ゲスト さん
Copyright (C) 2001-2025 hatena. All Rights Reserved.

[8]ページ先頭

©2009-2025 Movatter.jp