content-script.js 1008 B

1234567891011121314151617181920212223242526272829
  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. devTool: true,
  13. tool: 'hello-world'
  14. });
  15. }
  16. console.log('你好,我是来自FeHelper的工具Demo:hello world!');
  17. };
  18. /**
  19. * 如果在 fh-config.js 中指定了 noPage参数为true,则这里必须定义noPage的接口方法,如:
  20. * 注意这里的方法名称,其实是:window[`${toolName.replace(/[-_]/g,'')}NoPage`];
  21. * @author 阿烈叔
  22. */
  23. window.helloworldNoPage = function (tabInfo) {
  24. alert('你好,我是来自FeHelper的工具Demo:hello world!你可以打开控制台看Demo的输出!');
  25. console.log('你好,我是来自FeHelper的工具Demo:', tabInfo);
  26. };