-
-
Save HaKDMoDz/2d42cee599a4e685f9a148632bb61476 to your computer and use it in GitHub Desktop.
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div which contains a button element into the DOM! The function of the button is to remove google ads class from current site.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is the background code... | |
// listen for our browserAction to be clicked | |
chrome.browserAction.onClicked.addListener(function (tab) { | |
// for the current tab, inject the "inject.js" file & execute it | |
chrome.tabs.executeScript(tab.ib, { | |
file: 'inject.js' | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is the code which will be injected into a given page... | |
// containing function to create a div element attached to a button sub element | |
// the button removes all "adsbygoogle" classes from "ins" elements within the page. | |
// | |
(function() { | |
// just place a div at top right | |
var div = document.createElement('div'); | |
div.style.position = 'fixed'; | |
div.style.top = 0; | |
div.style.right = 0; | |
div.textContent = 'Injected!'; | |
document.body.appendChild(div); | |
var btn = document.createElement('button'); | |
btn.style.position = 'fixed'; | |
btn.style.backgroundColor = 'dodgerblue'; | |
btn.style.color = 'white'; | |
btn.textContent = 'Remove Google Ads'; | |
alert('Google Ad Removal Button!'); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Grief", | |
"version": "0.0.0", | |
"manifest_version": 1, | |
"description": "Injecting a button to remove googleAds class from current site", | |
"homepage_url": "http://youtube.com/user/hakdmodz/videos/index.html", | |
"background": { | |
"scripts": [ | |
"background.js" | |
], | |
"persistent": true | |
}, | |
"icons": { "16": "googleTrashed-Spun.png", | |
"48": "googleTrashed-Spun.png", | |
"128": "googleTrashed-Spun.png" }, | |
"browser_action": { | |
"default_title": "Grief" | |
}, | |
"author": "HaKDMoDz™", | |
"permissions": [ | |
"https://*/*", | |
"http://*/*", | |
"tabs" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my fork version attempts to remove those annoying google ads from a web page by using
danharper/background.js injection script for chrome browser extension.