Javascript 如何编辑某人';s的Facebook名称作为google chrome插件

Javascript 如何编辑某人';s的Facebook名称作为google chrome插件,javascript,html,facebook,google-chrome,Javascript,Html,Facebook,Google Chrome,我正在尝试从Facebook页面删除这些图片,并能够编辑每个“状态更新”名称。我可以删除图像,但不能更改状态更新名称。我已经试了好几个小时来做到这一点,我唯一能做到的就是改变特定的单词。我想浏览每一个并更改其中的“更改此文本”,我在我的facebook页面上附加了一个状态更新片段。谁能帮我一下吗?我尝试过使用javascript以及jquery,但在这两种语言中都无法理解。如果我需要进一步解释,请告诉我。谢谢 manifest.json { "name": "A browser action

我正在尝试从Facebook页面删除这些图片,并能够编辑每个“状态更新”名称。我可以删除图像,但不能更改状态更新名称。我已经试了好几个小时来做到这一点,我唯一能做到的就是改变特定的单词。我想浏览每一个
  • 并更改其中的“更改此文本”,我在我的facebook页面上附加了一个状态更新片段。谁能帮我一下吗?我尝试过使用
    javascript
    以及
    jquery
    ,但在这两种语言中都无法理解。如果我需要进一步解释,请告诉我。谢谢

    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);
    
    chrome.browserAction.onClicked.addListener(function(tab) {
      chrome.tabs.executeScript(
          null, {file: "changecolor.js"});
    });
    
    chrome.browserAction.setBadgeBackgroundColor({color:[0, 200, 0, 100]});
    
    background.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);
    
    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;\\u003C&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;s a 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>
    

  • 您需要的是一个DOM元素,它对于状态更新时的人员姓名是唯一的。看起来您需要包含actorDescription和actorName类的div。使用
    jQuery

    var nameSelector = "div.actorDescription.actorName";
    $(nameSelector).each(function() {
        $(this).text(replacementText);
    });
    
    当然,这实际上可能会改变太多事情;如果没有整个网页可以查看,很难说会有什么后果。如果这不起作用,您也可以尝试将nameSelector设置为
    a[href=”http://www.facebook.com/person']
    h5.uiStreamMessage.uiStreamHeadline