Chrome Extension

https://github.com/cloudware-deploy/chrome-extension

Google manifest is now v3.

Build for local

ruby build/build_v3.rb

Build for production

You will need Terser (ES6 minifier) -> npm install terser -g

ruby build/build_v3.rb production

How to Load Unpacked Version:

Build for local - instructions above. Go to: chrome://extensions/ Then 'Load Unpacked', and choose the folder called: [toconline/business]_extension inside the repo

How does it work

source_extension_manifest_v3/js/contentScript.js This file is where we establish communication with TOConline / Business. Some base64 hard-coded strings (platform and platform-extension) are exchanged as to establish a connection, just making it a little bit harder for curious unpackers of our extension.

source_extension_manifest_v3/src/bg/background.js This file is where the magic happens. It's a little hard to explain it all, but basically, it receives a payload, with the instructions to follow, making it as dynamic as possible, and thus making the payloads come from TOConline/Business, I've only ever changed this to add new features that weren't possible before.

Payload features are represented as:

  • Logout (url, timeout)

  • Login (url, actions*)

  • Follow = actions*

  • Finishing actions

Think of it as instructions for the extension to follow. actions* This is where we give instructions to the page. currently supports: (element-click, input-value, form-submit, fetch-json, get-element) and custom. The names should be pretty straight forward, you could do it all with custom, but the helpers help a lot (as intended).

You can see the payloads in the toconline repository: web-ui/src/vault-config.js "just_login" sample of AT (Autoridade Tributária)

just_login: {
  action: 'login-fetch-logout',
  logout: {
    url: 'https://www.acesso.gov.pt/logout?partID=PFIN&path=/pt/fecharSessao.action'
  },
  login: {
    url: 'https://www.acesso.gov.pt/jsp/loginRedirectForm.jsp?partID=PFIN',
    actions: [
      { type: 'input-value', element: '//*[@id="username"]', value: '{username}' },
      { type: 'input-value', element: '//*[@id="password-nif"]', value: '{password}', hidePassword: true },
      { type: 'form-submit', element: '//*[@id="loginForm"]' }
    ]
  }
}

Should be easy to understand. Also, notice element is always xPath (the parser is on the extension). Everything in {**} found in the payloads is to be replaced with the variables defined on the Acesso Direto page.

Last updated