Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use annyang in chrome extension #432

Open
realrecordzLab opened this issue Nov 26, 2020 · 1 comment
Open

Use annyang in chrome extension #432

realrecordzLab opened this issue Nov 26, 2020 · 1 comment

Comments

@realrecordzLab
Copy link

Is possible to integrate this inside a google chrome extension? I've Installed the library using npm and I'm using it inside the background script but it seems not working?

import annyang from 'annyang';

annyang.setLanguage('it-IT');

const commands = {
  'Chrome go to *site': openWebsite
}

const openWebsite = (site) => {
  console.log(site);
}

annyang.addCommands(commands);

chrome.browserAction.onClicked.addListener( (activeTab) => {
  console.log(activeTab);
  
  annyang.start({autoRestart: false, continuous: false });
  annyang.addCallback('start', (e) => {
    console.log(e);
  });
  //chrome.tabs.update();
});
@ndcg91
Copy link

ndcg91 commented Nov 25, 2021

You can load the annoying.min.js inside the webpage that gets affected by the extension and run your commands from there

const annyangScript = document.createElement('script');
annyangScript.setAttribute("type", "module");
annyangScript.setAttribute("src", chrome.runtime.getURL('js/managers/voiceManager/annyang.min.js'));
const annyangScriptHead = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
head.insertBefore(annyangScript, annyangScriptHead.firstChild);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants