Notes from Learning Chrome Extension Programming

Google Doc:
https://docs.google.com/document/d/e/2PACX-1vTdSIBV2ej7f_3rAw_6WgB6-o0jf9IJWOSpDIQuqKinRPwqJQz3W8RyHXf4u9dfd-AywQZ95nG8NPs7/pub

**
**

Notes GopherJS Chrome Extension Affirm Lang 1

Local Storage example: 1

March 15 2018  Session. 2

Events accessible by Chrome extensions 3

Actions that might be useful 3

Most direct Solution Found so Far 3

**
**

Notes GopherJS Chrome Extension Affirm Lang

**
**

https://godoc.org/github.com/gopherjs/gopherjs/js

**
**

http://localhost:8080/hellog/

**
**

https://github.com/gopherjs/gopherjs/wiki/JavaScript-Tips-and-Gotchas

**
**

sChrome Extension API: https://docs.google.com/spreadsheets/d/1P9CyaSm2gNqIGS0NSuTyrk4Oe2HAZaI8z_nq1Yec9oM/edit?usp=drive_web&ouid=115033250601381085689

**
**

A Shared app built in gopherjs  https://github.com/gopherjs/todomvc

**
**

So it’s a horrible choice to think in javascript dom and then write.  

**
**

Gopherjs could be a good option for Controller code.  Not for views of any kind.

**
**

Who can make me great at this?  Well it’s a good game. Somehow we should love on a lake.  Creeping thru wrong desires.

**
**

Local Storage example:

js.Global.Get(“localStorage”).Call(“setItem”, key, str)

item := js.Global.Get(“localStorage”).Call(“getItem”, key)

**
**

What’s the point of this:

type Router struct {

*js.Object

}

**
**

Js Object

**
**

So We have a decent example. No idea if your exampling is good.  

**
**

The full list of what an extension can do:

https://developer.chrome.com/extensions/devguide

**
**

  1. Extensions can interact with web pages or servers using content scripts

  2. orcross-origin XMLHttpRequests. Extensions can also interact programmatically with browser features such

  3. asbookmarks and tabs.

**
**

“google.golang.org/appengine/urlfetch

**
**

go get -u github.com/gocarina/gocsv

**
**

https://github.com/gocarina/gocsv

**
**

So where is csv via url?  

**
**

March 15 2018  Session.

**
**

https://app.asana.com/0/555190007041680/555190889021912

**
**

Need confirm gopherjs can produce calls to chrome features.

**
**

Finding: https://github.com/fabioberger/chrome

**
**

chrome://extensions/

file:///Users/darianhickman/go/src/hellog/popup.html

**
**

Replacing html:

https://www.gitbook.com/book/node-bloggers/creating-a-chrome-extension-popup-to-manipulate-t/details

https://docs.google.com/spreadsheets/d/1P9CyaSm2gNqIGS0NSuTyrk4Oe2HAZaI8z_nq1Yec9oM/edit#gid=0

https://stackoverflow.com/questions/38561136/chrome-extension-to-change-dom-with-a-button-in-extension-popup

**
**

So I know the target javascript to execute but not sure how to make my extension work.

https://stackoverflow.com/questions/2769525/chrome-extension-manifest-matches

https://developer.chrome.com/extensions/content_scripts

**
**

This worked for updating

**
**

chrome.browserAction.onClicked.addListener(function(tab) {
  // No tabs or host permissions needed!
  console.log('Turning ' + tab.url + ' red!');
  chrome.tabs.executeScript({
      code: 'document.body.innerHTML ="<div> Hello Darian </div>"'
  });d
});


Smart Cool

{
"name": "Page Redder",
"description": "Make the current page red",
"version": "2.0",
"permissions": [
  "activeTab"
],
"background": {
  "scripts": ["background.js"],
  "persistent": false
},
"browser_action": {
  "default_title": "Make this page red"
},
"manifest_version": 2
}

**
**

Events accessible by Chrome extensions

  1. onStartup

  2. onInstalled

  3. onSuspend

  4. onSuspendCanceled

  5. onUpdateAvailable

  6. onBrowserUpdateAvailable

  7. onConnect

  8. onConnectExternal

  9. onMessage

  10. onMessageExternal

  11. onRestartRequired

Actions that might be useful

  1. getURL

  2. reload

  3. getBackgroundPage

  4. sendMessage

**
**

Damn this implies what I want to do is completely disallowed

https://stackoverflow.com/questions/8627206/chrome-extension-external-url

But this implies it is possible:

https://stackoverflow.com/questions/25107774/how-do-i-send-an-http-get-request-in-chrome-extension

**
**

Most direct example yet:

**
**

chrome.tabs.query(object queryInfo, function callback)
To fix the preceding code, you must use that callback parameter. The following code shows how to define a callback function that gets the results from query() (as a parameter named tab) and calls update().
//THbb44wIS CODE WORKS
chrome.tabs.query({'active': true}, function(tabs) {
 chrome.tabs.update(tabs[0].id, {url: newUrl});
});
someOtherFunction();

**
**

Most direct Solution Found so Far

https://stackoverflow.com/questions/12065029/redirecting-url-in-a-chrome-extension

  1. The webRequest API, specifically the onBeforeRequest event. (Even better, the upcoming declarativeWebRequest API).

https://developer.chrome.com/extensions/webRequest

What is event page vs background page?  Man Chrome Browser super involved.

“persistent”: true

https://stackoverflow.com/questions/13326105/using-webrequest-api-with-event-page

Argh, stackoverflow has failed me.  Now going to try event page.

Fuck every example is failing.  

“name”: “Event Page Example” gives the following Failure:

**
**