jhen0409 / react-chrome-extension-boilerplate

Boilerplate for Chrome Extension React.js project
MIT License
2.14k stars 388 forks source link

allow extension for all urls? #67

Closed johnrosenbaud11 closed 7 years ago

johnrosenbaud11 commented 7 years ago

I am trying to allow the extension to work on all websites.

I modified the manifest.json (including the dev version) adding necessary permissions: "permissions": [ "contextMenus", "management", "tabs", "storage", "https://*/*", "<all_urls>" ],

but it doesn't help, it won't work. Apparently it only works on github, and the matter is dealt with by this variable, which, would only work for github.com (tried replacing it with other websites, won't work)

const arrowURLs = ['^https://github\\.com'];

any clues?

Thanks,

nickweinberg commented 7 years ago

I did this (in chrome/extension/background):

chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
  if (changeInfo.status !== 'loading') {
    return;
  }

  const result = await isInjected(tabId);
  if (chrome.runtime.lastError || result[0]) return;

  loadScript('inject', tabId, () => console.log('load inject bundle success!'));
});
jhen0409 commented 7 years ago

Yeah you can modify chrome/extension/background/inject.js.

frontr-uk commented 5 years ago

I got stuck as this did not work for me

e1jo commented 4 years ago

I got stuck as this did not work for me

try to add this on background.js (i pass empty object and this helped me)

chrome.runtime.onInstalled.addListener(function () { chrome.declarativeContent.onPageChanged.removeRules(undefined, function () { chrome.declarativeContent.onPageChanged.addRules([{ conditions: [new chrome.declarativeContent.PageStateMatcher({})], actions: [new chrome.declarativeContent.ShowPageAction()] } ]); }); });