私はこのhtmlをウェブページに持っています:
<select name="chapter_select" class="chapter_select">
<option value="http://www.example.com/chapter/1">Chapter 1</option>
<option value="http://www.example.com/chapter/2">Chapter 2</option>
<option value="http://www.example.com/chapter/3">Chapter 3</option>
<option value="http://www.example.com/chapter/4">Chapter 4</option>
<option value="http://www.example.com/chapter/5">Chapter 5</option>
<option value="http://www.example.com/chapter/6" selected="selected">Chapter 6</option>
</select>
そしてこの変数:
getInformationsFromCurrentPage : function(doc, curUrl, callback) {
//This function runs in the DOM of the current consulted page
var curChapName = $("select.chapter_select:first option:selected", doc).text();
var chapurl = $("select.chapter_select:first option:selected", doc).val();
callback({"name": name,
"currentChapter": curChapName,
"currentMangaURL": nameurl,
"currentChapterURL": chapurl});
},
}
問題は、両方が同じテキスト値を返すことです。chapurlは、テキスト値ではなくURLを返す必要があります。これは、Webサイトがサイトを変更するまで機能していました。
私はかなりうるさくなることを知っていますが、これは拡張機能の開発のためのマニュアルであり、doc変数は必須ですhttp://www.allmangasreader.com/dev.phpgetInformationsFromCurrentPage関数に注意してください。jQuery 1.4.2を使用しているので、おそらくそれは、他のサイトがそのまま機能するということです。
更新:サーバーはスクリプト(htmlの書き換え)を使用していたため、ドロップダウンリストが一番上にあると思いました。ソースに従って正しいセレクターを取得するために、いくつかのセレクターを使用しました。