I am attempting to remove the images from Facebook pages and be able to edit each "status update" name. I can remove images, but not change status update names. I have tried for hours to do this and the only way I have been able to is by changing specific words. I would like to go through each
javascript
as well as jquery
, but cannot figure it out in either. Please let me know if I need to explain anything further. Thanks! manifest.json
{ "name": "A browser action with no icon that makes the page red", "version": "1.0", "background": { "scripts": ["background.js"] }, "permissions": [ "tabs", "http://*/*" ], "browser_action": { "name": "Make this page red", "icons": ["icon.png"] }, "manifest_version": 2 }
changecolor.js
document.body.style.background='red'; //document.body.innerHTML = document.body.innerHTML.replace(new RegExp("the", "g"), "*the"); for (var i= document.images.length; i-->0;) document.images[i].parentNode.removeChild(document.images[i]); //element = document.getElementById("pagelet_home_stream"); //element.parentNode.removeChild(element);
background.js
chrome.browserAction.onClicked.addListener(function(tab) { chrome.tabs.executeScript( null, {file: "changecolor.js"}); }); chrome.browserAction.setBadgeBackgroundColor({color:[0, 200, 0, 100]});
Facebook HTML
<li class="uiUnifiedStory uiStreamStory genericStreamStory aid_100000145255153 aid_6628568379 uiListItem" data-ft="{"qid":"5834254800544145408","mf_story_key":"-6715439354839335346","has_expanded_ufi":"1"}" id="stream_story_50f76fd55fe2e1065042322" aria-haspopup="true"><div class="clearfix storyContent"><a class="actorPhoto lfloat" href="http://www.facebook.com/person" tabindex="-1" aria-hidden="true" data-ft="{"type":60,"tn":"\\\<"}" data-hovercard="/ajax/hovercard/hovercard.php?id=100000145255153"><img class="_s0 profilePic _rw img" src="http://profile.ak.fbcdn.net/hprofile-ak-ash4/371888_100000145255153_2142279014_q.jpg" alt="" /></a><div class="storyInnerContent"><div class="mainWrapper"><div role="article"><h5 class="uiStreamMessage uiStreamHeadline" data-ft="{"tn":":"}"><div class="actorDescription actorName" data-ft="{"type":2,"tn":":"}"><a href="http://www.facebook.com/person" data-ft="{"tn":";"}" data-hovercard="/ajax/hovercard/user.php?id=100000145255153">CHANGE THIS TEXT</a></div></h5><h5 class="uiStreamMessage userContentWrapper" data-ft="{"type":1,"tn":"K"}"> <span class="messageBody" data-ft="{"type":3}"><div><span class="userContent">Thanks everyone. In all honesty I actually forgot it was my birthday. I can't decide if it'sa sign of getting old, working too much, or just being sick.</span></div></span></h5><form rel="async" class="live_582871368394366_316526391751760 commentable_item autoexpand_mode" method="post" action="/ajax/ufi/modify.php" data-live="{"seq":"582871368394366_103294307"}" onsubmit="return window.Event && Event.__inlineSubmit && Event.__inlineSubmit(this,event)" id="u_ps_0_0_1a"><input type="hidden" name="charset_test" value="€,´,€,´,?,?,?" /><input type="hidden" name="fb_dtsg" value="AQDaIiR2" autocomplete="off" /><input type="hidden" autocomplete="off" name="feedback_params" value="{"actor":"100000145255153","target_fbid":"582871368394366","target_profile_id":"100000145255153","type_id":"22","assoc_obj_id":"","source_app_id":"0","extra_story_params":[],"content_timestamp":"1358390354","check_hash":"AQBKO-0F2rj_Yd6W","source":"13"}" /><input type="hidden" autocomplete="off" name="data_only_response" value="1" /><span class="uiStreamFooter"><span class="UIActionLinks UIActionLinks_bottom" data-ft="{"tn":"=","type":20}"><button title="Like this item" type="submit" name="like" onclick="fc_click(this, false); return true;" class="like_link stat_elem as_link" data-ft="{"tn":">","type":22}"><span class="default_message">Like</span><span class="saving_message">Unlike</span></button> · <label class="uiLinkButton comment_link" title="Leave a comment"><input data-ft="{"type":24,"tn":"S"}" type="button" value="Comment" onclick="return fc_click(this);" /></label> · </span><span class="uiStreamSource" data-ft="{"type":26,"tn":"N"}"><a href="/person/posts/582871368394366"><abbr title="Wednesday, January 16, 2013 at 9:39pm" data-utime="1358390354" class="timestamp livetimestamp">49 minutes ago</abbr></a> via <a href="/mobile/?v=6628568379">mobile</a></span> · <a data-hover="tooltip" class="uiStreamPrivacy inlineBlock fbStreamPrivacy fbPrivacyAudienceIndicator" href="#" id="u_ps_0_0_1b"><i class="lock img sp_bij1np sx_085ce0"></i></a></span><div><div class="uiUfi UFIContainer" id="u_ps_0_0_10"></div></div></form></div></div><div class="_6a mlm uiPopover highlightSelector uiStreamHide" data-ft="{"type":55,"tn":"V"}" id="u_ps_0_0_f"><a class="highlightSelectorButton uiStreamContextButton _p" href="#" aria-haspopup="true" aria-expanded="false" rel="toggle" id="u_ps_0_0_g">Options</a></div></div></div></li>
What you need is a DOM element that's unique for the names of people on status updates. It looks like you want the div with actorDescription and actorName classes. Using jQuery
:
var nameSelector = "div.actorDescription.actorName";
$(nameSelector).each(function() {
$(this).text(replacementText);
});
Of course, this might actually change too many things; it's hard to tell what the ramifications will be without the whole webpage to look at. If this doesn't work, you could also try setting nameSelector to a[href='http://www.facebook.com/person']
or h5.uiStreamMessage.uiStreamHeadline
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.