選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

background.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. function completeInitialization() {
  2. // Set the default background color of the action icon badge.
  3. chrome.browserAction.setBadgeBackgroundColor({
  4. color: "#0071b3"
  5. });
  6. /* Toggle the toolbar icon based on whether stickies are, or are not, set to
  7. be killed on the current tab, or update the badge with # of stickies killed.
  8. This listener receives a message from the content script (contentScript.js);
  9. the content script actually determines what the settings for the current
  10. tab are.
  11. */
  12. chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
  13. if (typeof request.killingStickies != "undefined") {
  14. let icons = request.killingStickies ?
  15. AKS.actionIcons.on :
  16. AKS.actionIcons.off;
  17. chrome.browserAction.setIcon({
  18. path: icons,
  19. tabId: request.tabID || sender.tab.id
  20. });
  21. } else if (typeof request.newBadgeText != "undefined") {
  22. chrome.browserAction.setBadgeText({
  23. tabId: sender.tab.id,
  24. text: request.newBadgeText
  25. });
  26. }
  27. });
  28. }
  29. function initialize() {
  30. window.AKS = { };
  31. var xhr = new XMLHttpRequest();
  32. xhr.onload = () => {
  33. AKS.actionIcons = JSON.parse(xhr.response);
  34. completeInitialization();
  35. };
  36. xhr.open('GET', chrome.extension.getURL('action_icons.json'), true);
  37. xhr.send();
  38. }
  39. initialize();