0

ユーザーがFacebookのようなボタンをクリックするとアラートを表示するChrome拡張機能を開発しています。

この目的でjQueryを使用していますが、機能していません。

ここにコードがあります

$("button").click(function(){
alert("Like");
});

いいねボタンがiframe内にあるため、このコードも試しましたが、まだうまくいきません!

var abc = $(document).find('iframe:first').contents().find('html:first').find('body:first');
abc.find("button").click(function(){
alert("Like");
});

manifest.json (このファイルにアクセス許可を追加しました)

"permissions": [
    "tabs", "http://*/*", "https://*/*", "http://*.facebook.com/", "https://*.facebook.com/"
]

どんな助けでも大歓迎です??

4

1 に答える 1

1

<a>最初の問題は、ほとんどの場合、「いいね」はボタンではないため、選択しないという事実かもしれません$('button')。クリックされたリンクの検出に関しては、likeこれが必要なすべてです。

マニフェスト.json

 "permissions": [
   "tabs","*://*.facebook.com/*"
 ],
 "content_scripts": [{
   "matches": ["*://*.facebook.com/*"],
   "js": ["jquery.js","click.js"]
 }]

click.js

// For most of the likes on things such as comments and pictures and all that
$('a.UFILikeLink').click(function(){
  console.log('Like link was clicked somewhere');
});
// For the Like 'Button' that can be found on pages 
$('input[value="Like"]').click(function(){
  console.log('Like button was clicked somewhere');
});
于 2013-05-05T22:59:41.383 に答える