Forem Creators and Builders 🌱

Ben Halpern
Ben Halpern

Posted on

Is the browser extension working for anyone?

Most of the feedback here was "this doesn't work!"

So here is round two. Browser extension working for anyone on Chrome?

Top comments (17)

Collapse
 
link2twenty profile image
Andrew Bone • Edited

Got it working.

I went to here
forem.com/valid_forems.json
Then suddenly it appeared on all my sites

EDIT: This was a red herring the bar appeared after the data was loaded, it just so happened I was on that page when it did.

hacker arms

Collapse
 
ben profile image
Ben Halpern

So it took you visiting that endpoint manually before it worked? πŸ€”

Collapse
 
link2twenty profile image
Andrew Bone

Did someone ask for an error?

Error handling response: TypeError: Cannot read property 'map' of undefined
    at myOrigins (chrome-extension://cobicbhlbogbkdcmgdhejghphaiofodb/content/content.js:204:19)
    at chrome-extension://cobicbhlbogbkdcmgdhejghphaiofodb/content/content.js:14:5
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
link2twenty profile image
Andrew Bone • Edited

I think I see it

chrome.storage.sync.get(['subscribedForems', 'allforems'], function (result) {
  const myForems = result.subscribedForems;
  const allForems = result.allforems;
  if (!myForems) {
    chrome.storage.sync.set({ subscribedForems: [] }); // Create empty array if not initialized.
  }
  if (!allForems) {
    chrome.storage.sync.set({ allforems: [] }); // Create empty array if not initialized.
  }
  // myOrigins(null) will break map on line 203
  if (
    myOrigins(myForems).includes(currentOrigin) ||
    validOrigins(allForems).includes(currentOrigin) ||
    currentOrigin === 'https://www.forem.com'
  ) {
    loadForemHTML(result.subscribedForems);
    document.addEventListener('add', handleAdd, false);
    document.addEventListener('remove', handleRemove, false);
    document.addEventListener('reorder', handleReorder, false);
  }
Enter fullscreen mode Exit fullscreen mode

This would remove the error though I've not thought the logic through yet

function myOrigins(myForems) {
  if(!myForems) return;
  return myForems.map(function (f) {
    return f.homePageUrl;
  });
}
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
link2twenty profile image
Andrew Bone

Another fix.

chrome.storage.sync.get(['subscribedForems', 'allforems'], function (result) {
  const myForems = result.subscribedForems ? result.subscribedForems : [];
  const allForems = result.allforems ? result.allforems : [];
  if (!result.subscribedForems) {
    chrome.storage.sync.set({ subscribedForems: [] }); // Create empty array if not initialized.
  }
  if (!result.allforems) {
    chrome.storage.sync.set({ allforems: [] }); // Create empty array if not initialized.
  }
  if (
    myOrigins(myForems).includes(currentOrigin) ||
    validOrigins(allForems).includes(currentOrigin) ||
    currentOrigin === 'https://www.forem.com'
  ) {
    loadForemHTML(result.subscribedForems);
    document.addEventListener('add', handleAdd, false);
    document.addEventListener('remove', handleRemove, false);
    document.addEventListener('reorder', handleReorder, false);
  }
Enter fullscreen mode Exit fullscreen mode
Collapse
 
link2twenty profile image
Andrew Bone • Edited

Yes I went there manually, when I started looking though the code and saw the bars existed in Dev and Forem suddenly.

Collapse
 
ben profile image
Ben Halpern

Then suddenly it appeared on all my sites

And is that all your sites like alll your sites or just Forems?

Thread Thread
 
link2twenty profile image
Andrew Bone

Sorry just forem sites

Collapse
 
citizen428 profile image
Michael Kohl

That worked for me too in Chrome.

Collapse
 
shiraazmoollatjie profile image
Shiraaz Moollatjie • Edited

Using mac + chrome

I eventually got it to work by uninstalling the old version, reinstalling the source and hard refreshing the pages.

I think I also managed to get it into an unusable state. This is how it may be reproduced:

  • Have no forems in the switcher
  • Go to the extension "home" (forem.com/discover)
  • Now add this "forem" to your sidebar, you can because the plus sign allows it.
  • Reload and you should get this error
Error handling response: TypeError: Cannot read property 'homePageUrl' of null
    at chrome-extension://kbbmmajekblbmamcpkopjkmihmddkpof/content/content.js:207:14
    at Array.map (<anonymous>)
    at myOrigins (chrome-extension://kbbmmajekblbmamcpkopjkmihmddkpof/content/content.js:206:19)
    at chrome-extension://kbbmmajekblbmamcpkopjkmihmddkpof/content/content.js:14:18
Enter fullscreen mode Exit fullscreen mode
Collapse
 
lee profile image
Lee

I tried. Followed instructions to install the extension from a folder. Nothing happens when I load up a forem or when I click on the forem extension. Should a forem load in the extension automatically?

Collapse
 
ben profile image
Ben Halpern

It should load automatically, but unsure why it would and wouldn't happen?

Collapse
 
arun profile image
Arun

I tried a few minutes and it didn't work for me in Chrome. :(

Collapse
 
ben profile image
Ben Halpern

Any error messages?

Collapse
 
arun profile image
Arun

Nope. I went to forem.com. First, it redirected me to forem.com/discover/ then nothing happened.

Collapse
 
apolloanumitha profile image
Anumitha Apollo

It seems to work perfectly fine for me!πŸ™Œ

Collapse
 
amorpheuz profile image
Yash Dave

I re-installed it and Hard Refreshed DEV and now it works on both Chrome and Edge!