content-script.js 985 B

12345678910111213141516171819202122232425262728
  1. let cssInjected = false;
  2. /**
  3. * 注意这里的方法名称,其实是:window[`${toolName.replace(/[-_]/g,'')}ContentScript`];
  4. * @author 阿烈叔
  5. */
  6. window.helloworldContentScript = function () {
  7. // 动态注入css
  8. if(!cssInjected) {
  9. chrome.runtime.sendMessage({
  10. type: 'fh-dynamic-any-thing',
  11. thing:'inject-content-css',
  12. tool: 'hello-world'
  13. });
  14. }
  15. console.log('你好,我是来自FeHelper的工具Demo:hello world!');
  16. };
  17. /**
  18. * 如果在 fh-config.js 中指定了 noPage参数为true,则这里必须定义noPage的接口方法,如:
  19. * 注意这里的方法名称,其实是:window[`${toolName.replace(/[-_]/g,'')}NoPage`];
  20. * @author 阿烈叔
  21. */
  22. window.helloworldNoPage = function (tabInfo) {
  23. alert('你好,我是来自FeHelper的工具Demo:hello world!你可以打开控制台看Demo的输出!');
  24. console.log('你好,我是来自FeHelper的工具Demo:', tabInfo);
  25. };