Skip to content

Instantly share code, notes, and snippets.

@messagetobala
Created February 10, 2023 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save messagetobala/4321ad2725df6df181e765a9e8946a37 to your computer and use it in GitHub Desktop.
Save messagetobala/4321ad2725df6df181e765a9e8946a37 to your computer and use it in GitHub Desktop.
let FILTERED_URLS = 'filtered_urls'
function modifyContent() {
document.body.textContent = ""
let bodyDiv = document.createElement('div')
bodyDiv.setAttribute("class", "watchdog_body")
let headerSection = document.createElement('section')
headerSection.setAttribute("class", "watchdog_header_section")
let headerPara_1 = document.createElement('p')
headerPara_1.setAttribute("class", "watchdog_para")
headerPara_1.textContent = 'A slight change in your daily habits can guide your life to a very different destination.'
let headerPara_2 = document.createElement('p')
headerPara_2.setAttribute("class", "watchdog_para")
headerPara_2.textContent = '- James Clear'
headerSection.appendChild(headerPara_1)
headerSection.appendChild(headerPara_2)
bodyDiv.appendChild(headerSection)
document.body.appendChild(bodyDiv)
}
function getHostname() {
return new URL(window.location.href).hostname
}
browser.storage.sync.get(FILTERED_URLS).then(function(items) {
if (items.hasOwnProperty(FILTERED_URLS) &&
items[FILTERED_URLS].includes(getHostname())) {
modifyContent();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment