I try to add a class to an element on Facebook page with a chrome extension. Unfortunately my script does not work... My goal is to select the posts containing an ad in the feed. All posts containers look similar, the only difference is the "sponsorized" tag which is the height child of the main container.
script.js:
var x = document.getElementsByClassName("uiStreamSponsoredLink").parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
x.className += "otherclass";
Manifest:
{
"name": "Project",
"version": "0.0.1",
"manifest_version": 2,
"default_locale": "en",
"icons": {
"16": "img/icon16.png",
"48": "img/icon48.png",
"128": "img/icon128.png"
},
"permissions": [
"*://*.facebook.com/*"
],
"content_scripts": [
{
"matches": [
"*://*.facebook.com/*"
],
"css": [
"content_script/replace-reactions.css"
],
"js": [
"content_script/script.js"
]
}
],
"web_accessible_resources": [
"img/*.png"
]
}