0

我正在尝试从 Facebook 页面中删除图像,并能够编辑每个“状态更新”名称。我可以删除图像,但不能更改状态更新名称。我已经尝试了几个小时来做​​到这一点,而我能够做到的唯一方法就是更改特定的单词。我想通过每一个

  • 并更改显示“更改此文本”的位置 我在我的 facebook 页面上附加了状态更新的片段。有人可以帮我吗?我试过使用javascriptas well as 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);
    

    background.js

    chrome.browserAction.onClicked.addListener(function(tab) {
      chrome.tabs.executeScript(
          null, {file: "changecolor.js"});
    });
    
    chrome.browserAction.setBadgeBackgroundColor({color:[0, 200, 0, 100]});
    

    脸书 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>
    
  • 4

    1 回答 1

    0

    您需要的是一个 DOM 元素,该元素对于状态更新中的人名是唯一的。看起来您想要带有 actorDescription 和 actorName 类的 div。使用jQuery

    var nameSelector = "div.actorDescription.actorName";
    $(nameSelector).each(function() {
        $(this).text(replacementText);
    });
    

    当然,这实际上可能会改变太多东西;如果不看整个网页,很难说后果会是什么。如果这不起作用,您也可以尝试将 nameSelector 设置为a[href='http://www.facebook.com/person']or h5.uiStreamMessage.uiStreamHeadline

    于 2013-09-04T19:44:44.640 回答