To format and validate your JSON, just copy + paste it below: About the JSONLint EditorJSONLint is a validator and reformatter for JSON, a lightweight data-interchange format. Copy and paste, directly type, or input a URL in the editor above and let JSONLint tidy and validate your messy JSON code. What Is JSON?JSON (pronounced as Jason), stands for "JavaScript Object Notation," is a human-readable
XPCNativeWrapperの外側でスクリプトを評価する関数。Firebugも同じことをしている。unsafeWindowを触らないので安全。 function evalInPage(fun) { location.href = "javascript:void (" + fun + ")()"; } SmartLDR更新 – 素人がプログラミングを勉強するブログ これは面白い!Function.prototype.toString が関数のソースコードを返すことを利用した、巧妙にして簡潔なハック。 次のように引数を渡せるように改良すればさらに強力になる(引数に渡せるのはJSON化可能な値のみ)。 function evalInPage(func, args) { var argStr = JSON.stringify(args || []); location.href = "jav
2008年06月18日16:00 カテゴリLightweight Languages javascript - Yet Another Base64 transcoder すでにJavaScriptによるBase64 Encodingの実装は複数あるのですが、これまた気に入った車輪がなかったので再発明。 dankogai's js-base64 at master - GitHub Demo Textにはencodeすべき文字列を、Base64にはdecodeすべき文字列を入力 TextBase64 (URL Safe ) Roundtripiframe w/ data: Discussion まず車輪の再発明に至った理由ですが、 Firefox 2以降とSafari 3.1以降には、window.atobならびにwindow.btoaが実装されているので、使える時にはこれを使いたかった。
JavaScript追記 2008/8/6現在のバージョンでは、はてなブックマークのタイトルを変更できない仕様になっています。逆に、変えたい場合にパッチ書いて当ててください。 Tombloo Hacks HatenaBookmark投稿時にtitleを配慮する - 枕を欹てて聴く そもそもTomblooのバグのような気がするけど。ハックしたりパッチしてもらえるのは、とてもうれしいです。あと、なんか迷惑かけてるかんじがして申し訳ないす。 今のTomblooは、addAroundとaddBeforeがある。addAroundは、とりあえずなんでもできる。前も書いたけど、アスペクトでやりたいこととして以下があって、一通りできる。 前処理 引数の変形呼び出しのキャンセル独自処理の置き換えターゲットオブジェクトの状態/メソッド名に合わせた処理の振り分け後処理 返り値の変形返り値の利用 コードにすると
bookmarkletのコンパイル(?)を簡素化するために、bookmarkletterなんてものを作ってはしゃいでたわけなんですが、調べてみると既に他にもたくさんあるようでした。 Bookmarklets Publish Kit - ブックマークレット・パブリッシュキットは知ってたんですが、まさかこんなにあるとは…。 というわけでそのまとめ。 Marklet BLOG: ブックマークレットを手軽に作るブックマークレット FF専用。これ自体がブックマークレットで実装されていてどこでも使える。 Side-X - ブックマークレットの作成を補助するフォーム セミコロンで改行ボタンが特徴的。IEだと折り返しの有無も設定できる。 WDF - Software : ブックマークレット作成スクリプト この中では一番最近に作られたもの?無名関数形式で結果を吐いてくれる。 ブックマークレット作成補助フォー
Greasemonkeyで@includeをhttp://*など広い範囲に指定しているとき、実行されるページにインラインフレーム(iframe)があると、そのiframe内でもGreasemonkeyスクリプトは実行されるのでややこしい事があります。 例えば、iframe pageのページにはiframeが2つあるので、下のようなスクリプトだと3回もlogが表示されるためiframeの存在に気づかないとスクリプトがバグってるのかと誤解します。 // ==UserScript== // @name iframe test // @namespace http://efcl.info/ // @include http://* // ==/UserScript== GM_log("テスト"); GM_log(location.href); // URLを表示すると意味が分かりやすい。 その
はじめに 「マンガでわかるJavaScript」は、難しそうに思えるプログラムを、簡単そうに見えるマンガで解説するという初心者向けの入門講座です。 架空の高校生たちに教える形式で、プログラムの基礎から応用を、解説していきます。一通りのマンガを読めば、かなり実践的なところまで、プログラムを書けるようにしていきます。 (マンガは、左上から右下へと読みます) プログラムというと、けっこう大変そうに思えますが、この講座のテーマは「面倒くさいことを楽にする」です。面倒臭がりで、手抜き大好きの女子高生を主人公にして、楽しくプログラムを学んでいくことにします。 主な対象読者は「これからプログラムを学んでみたい人」「Webの世界に関わっていてJavaScriptを学んでみたい人」「昔JavaScriptを触っていたけど最新のトレンドが分からないので改めて学んでみたい人」などです。初心者だけでなく、Webデ
Firefoxの拡張機能作りたい→作れないorz→userChrome.js?拡張機能を書けるぐりもん的な奴?→んでどうやって書くの? ということでGreasemonkeyスクリプトの開発で役に立ったサイトや本 - h1mesuke’s hoge-logのまんまオマージュの始まりですが、userChrome.jsスクリプトの開発方法をまとめてみようと常々思っていたのでまとめてみました。 追記(2010/03/31) 無名関数とか言っていたのをクロージャに書き換え&修正。 あとサンプルコードが全てまともに動いていませんでしたので修正または変更を行いました。 id:Griever さんへ。 この記事のミスの多さに自分で一切気づいておらず、このままだとひどいコードを晒したままになっていました。ブクマコメでの突っ込みホントありがとうございます。 userChrome.js userChrome.j
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。 jsの定義済みメソッドやプロパティの一覧欲しいなぁと思うことがあるんだけど、 意外となかったりするので、いろいろなサイトから集めて1ファイルにまとめてみた。 インプットはこちら。 Emeditorのjavascript自動補完を強化する - prog*sig Vim用の辞書ファイル - おつあり SHJS - License Plugins | jQuery Plugins Canvasリファレンス - HTML5.JP File API & Firefox 3.6 これらをjs1.js, js2.jsみたいなファイル名で保存。 で、以下の超適当なシェルでマージ。 (こういう作業はやっぱりunixなmacだとすぐできて楽ですね。) #!/bin/sh rm temp.js js.
タイトル変えました。旧タイトル「JavaScriptでよく使う書き方」。よく使うけど毎回忘れる。 正規表現にマッチするかどうか。 RegExp#testを使う。 /abc/.test("abcdefg") // => true String#searchはマッチした位置を返す。マッチしない場合は-1。先頭にマッチすると0でfalseなので注意。真偽値が欲しい場合はString#searchを使わない。 "abcdefg".search(/xxx/) // => -1 "abcdefg".search(/def/) // => 3 "abcdefg".search(/abc/) == false // => true 正規表現の部分マッチを得る。 部分マッチを得るには、RegExp#execかString#matchを使う。execとmatchの速度は大して変わらない。 正規表現のベンチマー
結論特定のclass属性を持った任意の要素にマッチするXPath(hogeは指定したいclass属性名) //*[contains(concat(" ",normalize-space(@class)," "), " hoge ")] 特定の要素にしたい場合は適当に div[contains(concat(" ",normalize-space(@class)," "), " hoge ")] などとする. 概要特定のclass属性を持った任意の要素にマッチするXPathというのはアドオンやUserJavaScript,スクレイピングの際にDOMノードを特定するために良く使いますが,XPathの書き方がマズイ人がたまにいます.普通に考えたらXPathはこうなります. XPath1:: //*[@class="hoge"] class属性は以下の引用部分に書かれているとおり,スタイルシート以
WordPress with Twitter の不具合を修正した記念に、Greasemonkey を書く時に頻繁に利用する関数をまとめたので、公開してみます。 外部の JavaScript ライブラリを読み込む方法を解説したサイトもありますが、そこまで大げさな機能が必要でもなく、軽く動作させたいときに便利です。 特に共通ライブラリを利用すると、Firefox 以外のブラウザの対応も無駄に読み込む事になるので、スマートじゃないなぁと思います。 var d = document; var $ = function(id) { return d.getElementById(id); } var $x = function(xp) { return d.evaluate(xp, d, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleN
Firefox3 の Greasemonkey, unsafeWindow 内の prototype がとれない - 冬通りに消え行く制服ガールは✖夢物語にリアルを求めない。 - subtechの件。 そろそろGreasemonkeyをFirefox3対応にしていきたいところだけど、この問題がすごく厄介。 例えば、はてなスターの星をプロフィールアイコンに置き換えるGreasemonkey Scriptメンテナンス更新 - 0xFFはFirefox2では動くけどFirefox3では動かない。 とりあえず、無理やり動かしてみる。 // ==UserScript== // @name replace star by profile icon // @namespace http://ss-o.net/ // @include http://*.hatena.ne.jp/* // @checkur
追記:最速インターフェース研究会 :: Firefoxでの開発を高速化する自動リロードスクリプトで既出でした。 デモを 2008-11-03_1209 - javascripter's library に置いた。 ライブラリ本体は javascripter's gist: 21788 — Gist にある。 (function () { var last = null; (function request() { with (new XMLHttpRequest()) { open('get', location.href, true); send(null); onload = function () { if (!last || last == this.responseText) { last = this.responseText; setTimeout(request, 500)
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く