简体   繁体   中英

How can I edit somebody's Facebook name as a google chrome add-on

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

  • and change where it says "CHANGE THIS TEXT" I have attached a snippet of a status update on my facebook page. Could somebody give me some help? I have tried using 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="&#123;&quot;qid&quot;:&quot;5834254800544145408&quot;,&quot;mf_story_key&quot;:&quot;-6715439354839335346&quot;,&quot;has_expanded_ufi&quot;:&quot;1&quot;&#125;" 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="&#123;&quot;type&quot;:60,&quot;tn&quot;:&quot;\\\<&quot;&#125;" 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="&#123;&quot;tn&quot;:&quot;:&quot;&#125;"><div class="actorDescription actorName" data-ft="&#123;&quot;type&quot;:2,&quot;tn&quot;:&quot;:&quot;&#125;"><a href="http://www.facebook.com/person" data-ft="&#123;&quot;tn&quot;:&quot;;&quot;&#125;" data-hovercard="/ajax/hovercard/user.php?id=100000145255153">CHANGE THIS TEXT</a></div></h5><h5 class="uiStreamMessage userContentWrapper" data-ft="&#123;&quot;type&quot;:1,&quot;tn&quot;:&quot;K&quot;&#125;"> <span class="messageBody" data-ft="&#123;&quot;type&quot;:3&#125;"><div><span class="userContent">Thanks everyone. In all honesty I actually forgot it was my birthday. I can&#039;t decide if it&#039;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="&#123;&quot;seq&quot;:&quot;582871368394366_103294307&quot;&#125;" onsubmit="return window.Event &amp;&amp; Event.__inlineSubmit &amp;&amp; Event.__inlineSubmit(this,event)" id="u_ps_0_0_1a"><input type="hidden" name="charset_test" value="&euro;,&acute;,€,´,?,?,?" /><input type="hidden" name="fb_dtsg" value="AQDaIiR2" autocomplete="off" /><input type="hidden" autocomplete="off" name="feedback_params" value="&#123;&quot;actor&quot;:&quot;100000145255153&quot;,&quot;target_fbid&quot;:&quot;582871368394366&quot;,&quot;target_profile_id&quot;:&quot;100000145255153&quot;,&quot;type_id&quot;:&quot;22&quot;,&quot;assoc_obj_id&quot;:&quot;&quot;,&quot;source_app_id&quot;:&quot;0&quot;,&quot;extra_story_params&quot;:[],&quot;content_timestamp&quot;:&quot;1358390354&quot;,&quot;check_hash&quot;:&quot;AQBKO-0F2rj_Yd6W&quot;,&quot;source&quot;:&quot;13&quot;&#125;" /><input type="hidden" autocomplete="off" name="data_only_response" value="1" /><span class="uiStreamFooter"><span class="UIActionLinks UIActionLinks_bottom" data-ft="&#123;&quot;tn&quot;:&quot;=&quot;,&quot;type&quot;:20&#125;"><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="&#123;&quot;tn&quot;:&quot;&gt;&quot;,&quot;type&quot;:22&#125;"><span class="default_message">Like</span><span class="saving_message">Unlike</span></button> &#183; <label class="uiLinkButton comment_link" title="Leave a comment"><input data-ft="&#123;&quot;type&quot;:24,&quot;tn&quot;:&quot;S&quot;&#125;" type="button" value="Comment" onclick="return fc_click(this);" /></label> &#183; </span><span class="uiStreamSource" data-ft="&#123;&quot;type&quot;:26,&quot;tn&quot;:&quot;N&quot;&#125;"><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="&#123;&quot;type&quot;:55,&quot;tn&quot;:&quot;V&quot;&#125;" 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.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM