Browser Extension - tattle-made/Uli GitHub Wiki
Content Script
Background Service Worker
Options Page
Tweet Control UI
When you visit a URL of the form http://twitter.com/*, Uli injects a content script into page. This script is located at browser extension/plugin/src/content-script.js
. This is the entry point for all Uli features.
The control flow is as follows :
βββββββββββββββββββββββββ βββββββββββββββββββββββββ
β set MutationObserver βββββonMutationββββΊβ check if added node β βββββββββββ
β on the <main> element β β is <section> βββNoβββΊβ Drop It β
βββββββββββββββββββββββββ βββββββββββββ¬ββββββββββββ βββββββββββ
β
Yes
β
βββββββββββββββββββββββββ βΌ
β set Message Listener β βββββββββββββββββββββ
β on Chrome Runtime ββββββonUrlChangeβββββ€ hande new page β
βββββββββββββββββββββββββ βββ¬ββββββββββββββββββ
β
β ββββββββββββββββββββββββββ
ββββββΌββΊβ process existing nodes β
β β ββββββββββββββββββββββββββ
β β
β β βββββββββββββββββββββββββββββ
β βββΊβset listener for new nodes β
β βββββββββββ¬ββββββββββββββββββ
β β
ββonNewNodeββββββββ
Prerequisite :
- a background service worker(
background.js
) that runs in the background all the time and sends a 'URL_CHANGED' message to the content script -
a chrome.runtime.onMessage
listener configured in thecontent-script.js
which processes the page whenever url changes
If anything breaks in this setup, the tweet control UI will work inconsistently. You will see that it is injected into the twitter UI correctly the first time you load a twitter page but if you click on any links within that page and arrive at a new page, it won't be injected on that page.
Every page has its getTimeline
function defined in src/twitter/pages
Try copy pasting it in your Browser's dev console