Use tabs.query, sendMessage and onMessage

Also make listenonrepeat work