mardi 21 avril 2015

Extension:Chrome.tabs.query does not work with 'url'

My extension to be click button on another page. I do not know why the code does not work. The function does not click on the item 'ac_play'

manifest

{
                    "manifest_version": 2,

                    "name": "VkPlayer", // Название расширения
                    "version": "1.0", // Номер версии
                    "description": "Switching music in the VK with the keyboard", // Описание расширения
                    "permissions": [
                        "tabs",
                        "*://vk.com/audios*"
                    ],
                    "background": {
                    "scripts": ["index.js"]
                   },
                    "browser_action": {
                    "default_title": "VKPlayer", // Название кнопки
                    "default_icon": "1.png", // Иконка для кнопки
                    "default_popup": "popup.html" // Всплывающее окно
                    }
                }

popup.html

 <script src="index.js"></script>
                        <style>body{
                            background: #2f4d9a;
                            width: 0;
                            height:0;
                        }</style>

index.js

function (tab) {
        chrome.tabs.query({'active': true},{'url':"http://vk.com/audio*"},function (tabs){
            console.log(tabs);
            chrome.tabs.executeScript(tabs[0].id, {code : "document.getElementById('ac_play').onclick();"});
        })
    }();

This code my website:

  <div id="ac_controls" class="fl_l">
            <div id="ac_play" class="fl_l"></div>
            <div class="next_prev fl_l">
              <div id="ac_prev" class="ctrl_wrap">
                <div class="prev ctrl"></div>
              </div>
              <div id="ac_next" class="ctrl_wrap">
                <div class="next ctrl"></div>
              </div>
            </div>
          </div>

Aucun commentaire:

Enregistrer un commentaire