I just started learning the basics of chrome extensions. Using a "Page Redder" extension, which changes the background color of the entire webpage, as a template I would like to make an extension that changes the background color of all text.
Page Redder from https://developer.chrome.com/extensions/samples: background.js:
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
// No tabs or host permissions needed!
console.log('Turning ' + tab.url + ' red!');
chrome.tabs.executeScript({
code: 'document.body.style.backgroundColor="red"'
});
});
manifest.json:
{
"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
}
Can I change the following lines of code to select all text instead?
chrome.tabs.executeScript({
code: 'document.body.style.backgroundColor="red"'
I tried changing it to:
chrome.tabs.insertCSS("content.css")
with content.css:
input[type='text']
{
background-color: red;
}
but with no success.
` tags or whatever `