使用javascript和"document.querySelector"事实证明,要成功地从Discord频道上的最后一条消息中识别和提取文本是很困难的。我在其他网站上成功地使用了:last-child,例如:
document.querySelector(“container:last-child”).innerContent
然而,这似乎在不和谐频道不起作用。它们的数据结构为嵌套的.div元素(而不是列表,我过去曾成功使用过)。下面是一个Discord结构的例子:
<div class="scrollerInner-2YIMLh" aria-label="Messages in 📘-rules-you-must-read" role="log" aria-orientation="vertical" data-list-id="chat-messages" tabindex="0" aria-live="off"><span class="navigationDescription-3hiGKr" id="messagesNavigationDescription" aria-hidden="true">Use the up and down arrow keys to navigate between messages quickly. New messages will be added to the bottom of the list as they come in.</span>
<div class="container-3RCQyg" id="chat-messages-701975798466216026">
<div class="container-3zqIcM">
<div class="inner-3GZ54g">
<div>
<div class="colorHeaderPrimary-26Jzh- size32-o_H79z titleName-3-Lp3Z">
<p>Welcome to</p>
<p>Nookazon</p>
</div>
<div class="colorHeaderSecondary-3Sp3Ft size14-e6ZScH subtitle-2UIIw0 noChildren-1pQQQE">This is the beginning of this server. </div>
</div>
</div>
</div>
</div>
<div class="message-2qnXI6 cozyMessage-3V1Y8y wrapper-2a6GCs cozy-3raOZG zalgo-jN1Ica" role="listitem" data-list-item-id="chat-messages___chat-messages-718562073835208774" tabindex="-1" id="chat-messages-718562073835208774">
<div class="contents-2mQqc9" role="document"><span class="latin24CompactTimeStamp-2V7XIQ timestamp-3ZCmNB timestampVisibleOnHover-2bQeI4 alt-1uNpEt"><span aria-label="1:29 PM"><i class="separator-2nZzUB" aria-hidden="true">[</i>1:29 PM<i class="separator-2nZzUB" aria-hidden="true">] </i></span></span>
<div class="markup-2BOw-j messageContent-2qWWxC"><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":eight:" src="/assets/71de2e3efd19455f1c63b9bd00329ec5.svg" alt=":eight:" draggable="false" class="emoji"></span> <strong>Spam</strong>
<div class="blockquoteContainer-U5TVEi">
<div class="blockquoteDivider-2hH8H6"></div>
<blockquote>Use of our website or Discord server in any way deemed to be spam will result in the termination of your account. This includes but is not limited to excessively using all capitalizations or spaces, and posting repeatedly, low effort, and/or inappropriate messages that contribute little to no meaning in the discussion regardless of timeframe, chain mail, or messages that are overall irrelevant. Excessively large messages, 15 lines or greater, are also considered spam, and will be dealt with accordingly. Please refrain from spamming pings, images, messages, or listings. Attempting to contact other users in any way for purposes deemed to be spam will not be tolerated. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":speech_balloon:" src="/assets/df8b5c1e4abb97e748071aeb28f1ba38.svg" alt=":speech_balloon:" draggable="false" class="emoji"></span> <strong>Use Chat and Trade Channels Appropriately</strong> Please use the appropriate trade channels for your discussions. All channel descriptions are located at the top of each channel. If you are unsure about where to post, please ask in <span class="wrapper-3WhCwL mention interactive" tabindex="0" role="button">#❔-help</span>. Punishments for trolling/baiting are more severe in the trading channels. You may receive a mute for any off-topic content in these channels. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":vibration_mode:" src="/assets/c039d0f4fb5cee040c7aa7c80da104d8.svg" alt=":vibration_mode:" draggable="false" class="emoji"></span> <strong>No Mass Pings</strong> Mass pinging individuals will result in an <em>auto-ban</em>. You may ping up to <strong><u>three</u></strong> mods or @ emergency if attention is needed in a channel. Abuse may result in a bite/ban. </blockquote>
</div><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":clipboard:" src="/assets/1bfac5a4300cf5668073bd17d178e89e.svg" alt=":clipboard:" draggable="false" class="emoji"></span> <strong>Keep your trading lists concise</strong>.
<div class="blockquoteContainer-U5TVEi">
<div class="blockquoteDivider-2hH8H6"></div>
<blockquote>If you have more than 10 items to trade per item category, please add them to your catalog on the site and share your Nookazon profile link in the appropriate trade channel. </blockquote>
</div><em> </em>
<time datetime="2021-01-04T04:35:25.481Z" class="edited-3sfAzf" role="note" aria-label="Sunday, January 3, 2021 8:35 PM">(edited)</time>
</div>
</div>
<div class="container-1ov-mD"></div>
</div>
<div class="message-2qnXI6 cozyMessage-3V1Y8y wrapper-2a6GCs cozy-3raOZG zalgo-jN1Ica" role="listitem" data-list-item-id="chat-messages___chat-messages-718562140486631455" tabindex="-1" id="chat-messages-718562140486631455">
<div class="contents-2mQqc9" role="document"><span class="latin24CompactTimeStamp-2V7XIQ timestamp-3ZCmNB timestampVisibleOnHover-2bQeI4 alt-1uNpEt"><span aria-label="1:29 PM"><i class="separator-2nZzUB" aria-hidden="true">[</i>1:29 PM<i class="separator-2nZzUB" aria-hidden="true">] </i></span></span>
<div class="markup-2BOw-j messageContent-2qWWxC"><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":keycap_ten:" src="/assets/5e1630b749695f21d61dcf55fc09c2b6.svg" alt=":keycap_ten:" draggable="false" class="emoji"></span> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":bangbang:" src="/assets/9a13b8821ec2c880981df4bf3ce07177.svg" alt=":bangbang:" draggable="false" class="emoji"></span><strong><u>Tarantula Bites</u></strong><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":bangbang:" src="/assets/9a13b8821ec2c880981df4bf3ce07177.svg" alt=":bangbang:" draggable="false" class="emoji"></span>
<div class="blockquoteContainer-U5TVEi">
<div class="blockquoteDivider-2hH8H6"></div>
<blockquote> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_blue_diamond:" src="/assets/85e5fb9f60873c46d98c8ab4efdf4066.svg" alt=":small_blue_diamond:" draggable="false" class="emoji"></span> Ignorance of our rules and policies is not considered a valid excuse for violating them. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_blue_diamond:" src="/assets/85e5fb9f60873c46d98c8ab4efdf4066.svg" alt=":small_blue_diamond:" draggable="false" class="emoji"></span> Failure to comply or respond to a request made by a staff member or moderator could result in punishment given at the discretion of staff member or moderator. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":tarantula:" src="https://cdn.discordapp.com/emojis/707342234743472218.png?v=1" alt=":tarantula:" draggable="false" class="emoji"></span> <strong>Tarantula Bite Strike System</strong> Individuals will receive one tarantula bite for an infraction of the rules. Individuals will be banned for high-severity infractions of the rules. The use of slurs, hate speech, offensive content, or Real Money Trading (RMT) are some examples of infractions that can result in an immediate ban. Punishments are based on your cumulative total of bites. Note that there are occurrences where you can be banned before 5 bites. <strong>Mutes</strong> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Two tarantula bites = 1 hour mute <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Three tarantula bites = 4 hour mute <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Four tarantula bites = 12 hour mute <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Five tarantula bites = Ban <em>Credit to Animal Crossing: New Horizon's Discord for Bug-Infraction Rule System!</em> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":pencil:" src="/assets/e1ec53c5d89c0291001989a36716aa9a.svg" alt=":pencil:" draggable="false" class="emoji"></span> <strong><u>REVIEW RULES</u></strong> <strong>The following are permitted reviews, regardless of star ranking:</strong> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":white_check_mark:" src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt=":white_check_mark:" draggable="false" class="emoji"></span> Completed trade <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":white_check_mark:" src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt=":white_check_mark:" draggable="false" class="emoji"></span> The user was rude when interacting with them Auctions-Specific: <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":white_check_mark:" src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt=":white_check_mark:" draggable="false" class="emoji"></span> Villager Auction was not completed after 24 hours* <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":white_check_mark:" src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt=":white_check_mark:" draggable="false" class="emoji"></span> Non-Villager Auction was not completed after 48 hours* <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":white_check_mark:" src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt=":white_check_mark:" draggable="false" class="emoji"></span> Auction canceled by seller/buyer* <strong>Leaving a review for these reasons is not permitted:</strong> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> As a requirement for trading/event hosting/giveaway. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Congratulating a user on milestone/achievement/giveaway without trade <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Trying to contact a user about a listing. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Reviews with abusive language/profanity <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Commenting on listings/pricing. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Reviews left in response to other reviews</blockquote>
</div>
<time datetime="2021-03-03T00:53:57.698Z" class="edited-3sfAzf" role="note" aria-label="Tuesday, March 2, 2021 4:53 PM">(edited)</time>
</div>
</div>
<div class="container-1ov-mD"></div>
<div class="buttonContainer-DHceWr">
<div class="buttons-cl5qTG container-3npvBV" aria-label="Message Actions">
<div class="wrapper-2aW0bm">
<div class="button-1ZiXG9" aria-label="More" aria-controls="popout_1628" aria-expanded="false" role="button" tabindex="0">
<svg class="icon-3Gkjwa" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24">
<path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M7 12.001C7 10.8964 6.10457 10.001 5 10.001C3.89543 10.001 3 10.8964 3 12.001C3 13.1055 3.89543 14.001 5 14.001C6.10457 14.001 7 13.1055 7 12.001ZM14 12.001C14 10.8964 13.1046 10.001 12 10.001C10.8954 10.001 10 10.8964 10 12.001C10 13.1055 10.8954 14.001 12 14.001C13.1046 14.001 14 13.1055 14 12.001ZM19 10.001C20.1046 10.001 21 10.8964 21 12.001C21 13.1055 20.1046 14.001 19 14.001C17.8954 14.001 17 13.1055 17 12.001C17 10.8964 17.8954 10.001 19 10.001Z"></path>
</svg>
</div>
</div>
</div>
</div>
</div>
<div class="message-2qnXI6 cozyMessage-3V1Y8y wrapper-2a6GCs cozy-3raOZG zalgo-jN1Ica" role="listitem" data-list-item-id="chat-messages___chat-messages-718562178684158015" tabindex="-1" id="chat-messages-718562178684158015">
<div class="contents-2mQqc9" role="document"><span class="latin24CompactTimeStamp-2V7XIQ timestamp-3ZCmNB timestampVisibleOnHover-2bQeI4 alt-1uNpEt"><span aria-label="1:29 PM"><i class="separator-2nZzUB" aria-hidden="true">[</i>1:29 PM<i class="separator-2nZzUB" aria-hidden="true">] </i></span></span>
<div class="markup-2BOw-j messageContent-2qWWxC">
<div class="blockquoteContainer-U5TVEi">
<div class="blockquoteDivider-2hH8H6"></div>
<blockquote><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Commenting on listings/pricing <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Reviews left in response to other reviews <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Reviewing on behalf of other users <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Canceled Trades (buyer or seller) <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Auction ended and never heard a response BEFORE 48 Hours (24 hours for Villagers) * Please note that multiple failed auctions is a reportable offense, and can result in strikes/bans. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":judge:" src="/assets/581744e66dae5ebd54b563d527478f93.svg" alt=":judge:" draggable="false" class="emoji"></span> <strong><u>Auction Rules</u></strong> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> If the buyer (i.e. winner of the auction) or the seller does not follow through with the transaction within 48 hours, the buyer or seller has the right to report that user. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Depending on the circumstance, Nookazon has the right to bite and/or ban users for not following through with auctions. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Auctions cannot be cancelled once a bid has been made. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Bids made on the site must be honored. Cross-platform auctions between site and server are prohibited. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Attempts to haggle with the buyer after an auction has been won are not allowed. </blockquote>
</div>
<div class="blockquoteContainer-U5TVEi">
<div class="blockquoteDivider-2hH8H6"></div>
<blockquote><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":warning:" src="/assets/289673858e06dfa2e0e3a7ee610c3a30.svg" alt=":warning:" draggable="false" class="emoji"></span> <strong><u>DISCLAIMER</u></strong> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":warning:" src="/assets/289673858e06dfa2e0e3a7ee610c3a30.svg" alt=":warning:" draggable="false" class="emoji"></span> These rules are NOT exhaustive. Just because it is not listed, does NOT mean it is allowed. Check the pins by clicking the<span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":pushpin:" src="/assets/09204f6a96455580e749454b7449aa82.svg" alt=":pushpin:" draggable="false" class="emoji"></span> in each channel for important rules, guidelines, etc. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":revolving_hearts:" src="/assets/430e873bc74e81778ccf63f5d440f0ca.svg" alt=":revolving_hearts:" draggable="false" class="emoji"></span> Friendly reminder that all mods are humans, not robots. They do their best to respond to all issues in a timely manner and to their best discretion. <em>If you would like to submit a mod appreciation letter, you can do so by typing ?send in any channel</em>! If you have a concern with moderation practices or a particular member of our moderation team, please submit a report via <a class="anchor-3Z-8Bb anchorUnderlineOnHover-2ESHQB" title="xxxxx" href="xxxxx" rel="noreferrer noopener" target="_blank" role="button" tabindex="0">xxxxx</a>. These reports are handled by non-moderation team Nookazon staff to ensure fair and unbiased reviews. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":nookazon:" src="https://cdn.discordapp.com/emojis/705612765561094174.png?v=1" alt=":nookazon:" draggable="false" class="emoji"></span> <strong>We hope you enjoy your time here with Nookazon!</strong> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":white_check_mark:" src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt=":white_check_mark:" draggable="false" class="emoji"></span><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":ballot_box_with_check:" src="/assets/86c16c39d96283551fd4ca7392e22681.svg" alt=":ballot_box_with_check:" draggable="false" class="emoji"></span> By clicking either check mark, you indicate that you have read and agree to abide by the above rules and policies, and you understand that these rules and policies are not exhaustive and are subject to change.</blockquote>
</div>
<time datetime="2021-03-03T00:54:27.794Z" class="edited-3sfAzf" role="note" aria-label="Tuesday, March 2, 2021 4:54 PM">(edited)</time>
</div>
</div>
<div class="container-1ov-mD">
<div class="reactions-12N0jA" role="group" aria-label="Reactions">
<div>
<div class="reaction-1hd86g" style="opacity: 1;">
<div aria-controls="popout_1620" aria-expanded="false">
<div class="reactionInner-15NvIl" aria-label="✅, press to react" aria-pressed="false"><img src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt="✅" draggable="false" class="emoji">
<div class="reactionCount-2mvXRV" style="min-width: 45px;">15271</div>
</div>
</div>
</div>
</div>
<div>
<div class="reaction-1hd86g" style="opacity: 1;">
<div aria-controls="popout_1621" aria-expanded="false">
<div class="reactionInner-15NvIl" aria-label="☑️, press to react" aria-pressed="false"><img src="/assets/86c16c39d96283551fd4ca7392e22681.svg" alt="☑️" draggable="false" class="emoji">
<div class="reactionCount-2mvXRV" style="min-width: 36px;">9731</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="buttonContainer-DHceWr">
<div class="buttons-cl5qTG container-3npvBV" aria-label="Message Actions">
<div class="wrapper-2aW0bm">
<div class="button-1ZiXG9" aria-label="More" aria-controls="popout_1627" aria-expanded="false" role="button" tabindex="0">
<svg class="icon-3Gkjwa" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24">
<path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M7 12.001C7 10.8964 6.10457 10.001 5 10.001C3.89543 10.001 3 10.8964 3 12.001C3 13.1055 3.89543 14.001 5 14.001C6.10457 14.001 7 13.1055 7 12.001ZM14 12.001C14 10.8964 13.1046 10.001 12 10.001C10.8954 10.001 10 10.8964 10 12.001C10 13.1055 10.8954 14.001 12 14.001C13.1046 14.001 14 13.1055 14 12.001ZM19 10.001C20.1046 10.001 21 10.8964 21 12.001C21 13.1055 20.1046 14.001 19 14.001C17.8954 14.001 17 13.1055 17 12.001C17 10.8964 17.8954 10.001 19 10.001Z"></path>
</svg>
</div>
</div>
</div>
</div>
</div>
<div class="divider-3_HH5L hasContent-1_DUdQ divider-JfaTT5 hasContent-1cNJDh"><span class="content-1o0f9g">June 8, 2020</span></div>
<div class="message-2qnXI6 cozyMessage-3V1Y8y groupStart-23k01U wrapper-2a6GCs cozy-3raOZG zalgo-jN1Ica" role="listitem" data-list-item-id="chat-messages___chat-messages-719650608935731211" tabindex="-1" id="chat-messages-719650608935731211">
<div class="contents-2mQqc9" role="document"><img src="https://cdn.discordapp.com/avatars/717491799014506551/7915934d00f156ee499963d2c14ecdf8.png?size=256" aria-hidden="true" class="avatar-1BDn8e clickable-1bVtEA" alt=" ">
<h2 class="header-23xsNx"><span class="headerText-3Uvj1Y"><span class="username-1A8OIy clickable-1bVtEA" aria-controls="popout_1623" aria-expanded="false" role="button" tabindex="0">nookazon</span></span><span class="timestamp-3ZCmNB"><span aria-label="06/08/2020">06/08/2020</span></span></h2>
<div class="markup-2BOw-j messageContent-2qWWxC"><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":arrow_up:" src="/assets/b51c7cfe515fd884537ca5c2ac8ce7a2.svg" alt=":arrow_up:" draggable="false" class="emoji"></span> If you <strong>do not</strong> see the checkmarks under the above message, make sure you have Reaction Emojis enabled in your Discord settings.
<div class="blockquoteContainer-U5TVEi">
<div class="blockquoteDivider-2hH8H6"></div>
<blockquote>Go to User Settings <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":gear:" src="/assets/a6d05968d7706183143518d96c9f066e.svg" alt=":gear:" draggable="false" class="emoji"></span> → Text & Images → Emoji <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":warning:" src="/assets/289673858e06dfa2e0e3a7ee610c3a30.svg" alt=":warning:" draggable="false" class="emoji"></span> If you are having trouble receiving full access, make sure that you have reacted to get the role. After, <em>please wait up to 10 minutes</em> due to traffic as the bot can get overloaded. If this doesn't work, <em>restart Discord</em> (control/command R), then attempt to click on it again. If you are still having troubles, please ask in <span class="wrapper-3WhCwL mention interactive" tabindex="0" role="button">#❔-help</span> after you have attempted the troubleshooting methods above.</blockquote>
</div>
</div>
</div>
<div class="container-1ov-mD"></div>
</div>
<div class="scrollerSpacer-avRLaA"></div>
</div>
我正在尝试从最后一条消息中获取文本- xxxxx "条目。所以我试过了:
document.querySelector(“div.scrollerInner-XXXXX:last-child”).innerContent
但它似乎不起作用。我写的代码对吗?我还想知道嵌套的scrollerspacer是否最后就是把东西扔掉。我不是100%相信这是情况,因为当我使用inspect-elements删除它时,脚本仍然失败。
任何帮助都将是非常感激的。
Thank you -S
因为看起来最后一个元素后面跟着
<div class="scrollerSpacer-XXXXXX"><div>
我选择那个元素,然后导航到它的前一个兄弟元素:
const spacer = document.querySelector('[class^="scrollerSpacer"]');
const finalMessageElement = spacer.previousElementSibling
console.log(finalMessageElement);
console.log(finalMessageElement.textContent);
<div class="scrollerInner-2YIMLh" aria-label="Messages in 📘-rules-you-must-read" role="log" aria-orientation="vertical" data-list-id="chat-messages" tabindex="0" aria-live="off"><span class="navigationDescription-3hiGKr" id="messagesNavigationDescription" aria-hidden="true">Use the up and down arrow keys to navigate between messages quickly. New messages will be added to the bottom of the list as they come in.</span>
<div class="container-3RCQyg" id="chat-messages-701975798466216026">
<div class="container-3zqIcM">
<div class="inner-3GZ54g">
<div>
<div class="colorHeaderPrimary-26Jzh- size32-o_H79z titleName-3-Lp3Z">
<p>Welcome to</p>
<p>Nookazon</p>
</div>
<div class="colorHeaderSecondary-3Sp3Ft size14-e6ZScH subtitle-2UIIw0 noChildren-1pQQQE">This is the beginning of this server. </div>
</div>
</div>
</div>
</div>
<div class="message-2qnXI6 cozyMessage-3V1Y8y wrapper-2a6GCs cozy-3raOZG zalgo-jN1Ica" role="listitem" data-list-item-id="chat-messages___chat-messages-718562073835208774" tabindex="-1" id="chat-messages-718562073835208774">
<div class="contents-2mQqc9" role="document"><span class="latin24CompactTimeStamp-2V7XIQ timestamp-3ZCmNB timestampVisibleOnHover-2bQeI4 alt-1uNpEt"><span aria-label="1:29 PM"><i class="separator-2nZzUB" aria-hidden="true">[</i>1:29 PM<i class="separator-2nZzUB" aria-hidden="true">] </i></span></span>
<div class="markup-2BOw-j messageContent-2qWWxC"><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":eight:" src="/assets/71de2e3efd19455f1c63b9bd00329ec5.svg" alt=":eight:" draggable="false" class="emoji"></span> <strong>Spam</strong>
<div class="blockquoteContainer-U5TVEi">
<div class="blockquoteDivider-2hH8H6"></div>
<blockquote>Use of our website or Discord server in any way deemed to be spam will result in the termination of your account. This includes but is not limited to excessively using all capitalizations or spaces, and posting repeatedly, low effort, and/or
inappropriate messages that contribute little to no meaning in the discussion regardless of timeframe, chain mail, or messages that are overall irrelevant. Excessively large messages, 15 lines or greater, are also considered spam, and will
be dealt with accordingly. Please refrain from spamming pings, images, messages, or listings. Attempting to contact other users in any way for purposes deemed to be spam will not be tolerated. <span class="emojiContainer-3X8SvE" role="button"
tabindex="0"><img aria-label=":speech_balloon:" src="/assets/df8b5c1e4abb97e748071aeb28f1ba38.svg" alt=":speech_balloon:" draggable="false" class="emoji"></span> <strong>Use Chat and Trade Channels Appropriately</strong> Please use the appropriate
trade channels for your discussions. All channel descriptions are located at the top of each channel. If you are unsure about where to post, please ask in <span class="wrapper-3WhCwL mention interactive" tabindex="0" role="button">#❔-help</span>.
Punishments for trolling/baiting are more severe in the trading channels. You may receive a mute for any off-topic content in these channels. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":vibration_mode:" src="/assets/c039d0f4fb5cee040c7aa7c80da104d8.svg" alt=":vibration_mode:" draggable="false" class="emoji"></span> <strong>No Mass Pings</strong> Mass pinging individuals will result in an <em>auto-ban</em>. You may ping up to <strong><u>three</u></strong> mods or @ emergency if attention is needed in a channel. Abuse may result in a bite/ban. </blockquote>
</div><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":clipboard:" src="/assets/1bfac5a4300cf5668073bd17d178e89e.svg" alt=":clipboard:" draggable="false" class="emoji"></span> <strong>Keep your trading lists concise</strong>.
<div class="blockquoteContainer-U5TVEi">
<div class="blockquoteDivider-2hH8H6"></div>
<blockquote>If you have more than 10 items to trade per item category, please add them to your catalog on the site and share your Nookazon profile link in the appropriate trade channel. </blockquote>
</div><em> </em>
<time datetime="2021-01-04T04:35:25.481Z" class="edited-3sfAzf" role="note" aria-label="Sunday, January 3, 2021 8:35 PM">(edited)</time>
</div>
</div>
<div class="container-1ov-mD"></div>
</div>
<div class="message-2qnXI6 cozyMessage-3V1Y8y wrapper-2a6GCs cozy-3raOZG zalgo-jN1Ica" role="listitem" data-list-item-id="chat-messages___chat-messages-718562140486631455" tabindex="-1" id="chat-messages-718562140486631455">
<div class="contents-2mQqc9" role="document"><span class="latin24CompactTimeStamp-2V7XIQ timestamp-3ZCmNB timestampVisibleOnHover-2bQeI4 alt-1uNpEt"><span aria-label="1:29 PM"><i class="separator-2nZzUB" aria-hidden="true">[</i>1:29 PM<i class="separator-2nZzUB" aria-hidden="true">] </i></span></span>
<div class="markup-2BOw-j messageContent-2qWWxC"><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":keycap_ten:" src="/assets/5e1630b749695f21d61dcf55fc09c2b6.svg" alt=":keycap_ten:" draggable="false" class="emoji"></span> <span class="emojiContainer-3X8SvE" role="button"
tabindex="0"><img aria-label=":bangbang:" src="/assets/9a13b8821ec2c880981df4bf3ce07177.svg" alt=":bangbang:" draggable="false" class="emoji"></span><strong><u>Tarantula Bites</u></strong><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":bangbang:" src="/assets/9a13b8821ec2c880981df4bf3ce07177.svg" alt=":bangbang:" draggable="false" class="emoji"></span>
<div class="blockquoteContainer-U5TVEi">
<div class="blockquoteDivider-2hH8H6"></div>
<blockquote> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_blue_diamond:" src="/assets/85e5fb9f60873c46d98c8ab4efdf4066.svg" alt=":small_blue_diamond:" draggable="false" class="emoji"></span> Ignorance of our rules
and policies is not considered a valid excuse for violating them. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_blue_diamond:" src="/assets/85e5fb9f60873c46d98c8ab4efdf4066.svg" alt=":small_blue_diamond:" draggable="false" class="emoji"></span> Failure to comply or respond to a request made by a staff member or moderator could result in punishment given at the discretion of staff member or moderator. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":tarantula:" src="https://cdn.discordapp.com/emojis/707342234743472218.png?v=1" alt=":tarantula:" draggable="false" class="emoji"></span> <strong>Tarantula Bite Strike System</strong> Individuals will receive one tarantula bite for an infraction of the rules. Individuals will be banned for high-severity infractions of the rules. The use of slurs, hate speech, offensive content,
or Real Money Trading (RMT) are some examples of infractions that can result in an immediate ban. Punishments are based on your cumulative total of bites. Note that there are occurrences where you can be banned before 5 bites. <strong>Mutes</strong> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Two tarantula bites
= 1 hour mute <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Three
tarantula bites = 4 hour mute <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Four tarantula bites = 12 hour mute <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Five tarantula bites = Ban <em>Credit to Animal Crossing: New Horizon's Discord for Bug-Infraction Rule System!</em> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":pencil:" src="/assets/e1ec53c5d89c0291001989a36716aa9a.svg" alt=":pencil:" draggable="false" class="emoji"></span> <strong><u>REVIEW RULES</u></strong> <strong>The following are permitted reviews, regardless of star ranking:</strong> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":white_check_mark:" src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt=":white_check_mark:" draggable="false" class="emoji"></span> Completed trade <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":white_check_mark:" src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt=":white_check_mark:" draggable="false" class="emoji"></span> The user
was rude when interacting with them Auctions-Specific: <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":white_check_mark:" src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt=":white_check_mark:" draggable="false" class="emoji"></span> Villager Auction was not completed after 24 hours* <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":white_check_mark:" src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt=":white_check_mark:" draggable="false" class="emoji"></span> Non-Villager Auction was not completed after 48 hours* <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":white_check_mark:" src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt=":white_check_mark:" draggable="false" class="emoji"></span> Auction canceled by seller/buyer* <strong>Leaving a review for these reasons is not permitted:</strong> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> As a requirement for trading/event hosting/giveaway. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Congratulating a user on milestone/achievement/giveaway without trade <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Trying to contact a user about a listing. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Reviews with
abusive language/profanity <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Commenting on listings/pricing.
<span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Reviews left in response to other reviews</blockquote>
</div>
<time datetime="2021-03-03T00:53:57.698Z" class="edited-3sfAzf" role="note" aria-label="Tuesday, March 2, 2021 4:53 PM">(edited)</time>
</div>
</div>
<div class="container-1ov-mD"></div>
<div class="buttonContainer-DHceWr">
<div class="buttons-cl5qTG container-3npvBV" aria-label="Message Actions">
<div class="wrapper-2aW0bm">
<div class="button-1ZiXG9" aria-label="More" aria-controls="popout_1628" aria-expanded="false" role="button" tabindex="0">
<svg class="icon-3Gkjwa" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24">
<path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M7 12.001C7 10.8964 6.10457 10.001 5 10.001C3.89543 10.001 3 10.8964 3 12.001C3 13.1055 3.89543 14.001 5 14.001C6.10457 14.001 7 13.1055 7 12.001ZM14 12.001C14 10.8964 13.1046 10.001 12 10.001C10.8954 10.001 10 10.8964 10 12.001C10 13.1055 10.8954 14.001 12 14.001C13.1046 14.001 14 13.1055 14 12.001ZM19 10.001C20.1046 10.001 21 10.8964 21 12.001C21 13.1055 20.1046 14.001 19 14.001C17.8954 14.001 17 13.1055 17 12.001C17 10.8964 17.8954 10.001 19 10.001Z"></path>
</svg>
</div>
</div>
</div>
</div>
</div>
<div class="message-2qnXI6 cozyMessage-3V1Y8y wrapper-2a6GCs cozy-3raOZG zalgo-jN1Ica" role="listitem" data-list-item-id="chat-messages___chat-messages-718562178684158015" tabindex="-1" id="chat-messages-718562178684158015">
<div class="contents-2mQqc9" role="document"><span class="latin24CompactTimeStamp-2V7XIQ timestamp-3ZCmNB timestampVisibleOnHover-2bQeI4 alt-1uNpEt"><span aria-label="1:29 PM"><i class="separator-2nZzUB" aria-hidden="true">[</i>1:29 PM<i class="separator-2nZzUB" aria-hidden="true">] </i></span></span>
<div class="markup-2BOw-j messageContent-2qWWxC">
<div class="blockquoteContainer-U5TVEi">
<div class="blockquoteDivider-2hH8H6"></div>
<blockquote><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Commenting on listings/pricing <span class="emojiContainer-3X8SvE"
role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Reviews left in response to other reviews <span class="emojiContainer-3X8SvE" role="button"
tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Reviewing on behalf of other users <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Canceled Trades (buyer or seller) <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":x:" src="/assets/8becd37ab9d13cdfe37c08c496a9def3.svg" alt=":x:" draggable="false" class="emoji"></span> Auction ended and never
heard a response BEFORE 48 Hours (24 hours for Villagers) * Please note that multiple failed auctions is a reportable offense, and can result in strikes/bans. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":judge:" src="/assets/581744e66dae5ebd54b563d527478f93.svg" alt=":judge:" draggable="false" class="emoji"></span> <strong><u>Auction Rules</u></strong> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> If the buyer (i.e. winner of the auction) or the seller does not follow through with the transaction within 48 hours, the buyer or seller has the right to report that user. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Depending on the circumstance, Nookazon has the right to bite and/or ban users for not following through with auctions. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Auctions cannot be cancelled once a bid has been made. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Bids made on the site must be honored. Cross-platform auctions between site and server are prohibited. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":small_orange_diamond:" src="/assets/893165570015b53aad1a6999d13ea7d8.svg" alt=":small_orange_diamond:" draggable="false" class="emoji"></span> Attempts to haggle with the buyer after an auction has been won are not allowed. </blockquote>
</div>
<div class="blockquoteContainer-U5TVEi">
<div class="blockquoteDivider-2hH8H6"></div>
<blockquote><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":warning:" src="/assets/289673858e06dfa2e0e3a7ee610c3a30.svg" alt=":warning:" draggable="false" class="emoji"></span> <strong><u>DISCLAIMER</u></strong> <span class="emojiContainer-3X8SvE"
role="button" tabindex="0"><img aria-label=":warning:" src="/assets/289673858e06dfa2e0e3a7ee610c3a30.svg" alt=":warning:" draggable="false" class="emoji"></span> These rules are NOT exhaustive. Just because it is not listed, does NOT mean
it is allowed. Check the pins by clicking the<span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":pushpin:" src="/assets/09204f6a96455580e749454b7449aa82.svg" alt=":pushpin:" draggable="false" class="emoji"></span> in each channel for important rules, guidelines, etc. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":revolving_hearts:" src="/assets/430e873bc74e81778ccf63f5d440f0ca.svg" alt=":revolving_hearts:" draggable="false" class="emoji"></span> Friendly reminder that all mods are humans, not robots. They do their best to respond to all issues in a timely manner and to their best discretion. <em>If you would like to submit a mod appreciation letter, you can do so by typing ?send in any channel</em>!
If you have a concern with moderation practices or a particular member of our moderation team, please submit a report via <a class="anchor-3Z-8Bb anchorUnderlineOnHover-2ESHQB" title="xxxxx" href="xxxxx" rel="noreferrer noopener" target="_blank"
role="button" tabindex="0">xxxxx</a>. These reports are handled by non-moderation team Nookazon staff to ensure fair and unbiased reviews. <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":nookazon:" src="https://cdn.discordapp.com/emojis/705612765561094174.png?v=1" alt=":nookazon:" draggable="false" class="emoji"></span> <strong>We hope you enjoy your time here with Nookazon!</strong> <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":white_check_mark:" src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt=":white_check_mark:" draggable="false" class="emoji"></span>
<span
class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":ballot_box_with_check:" src="/assets/86c16c39d96283551fd4ca7392e22681.svg" alt=":ballot_box_with_check:" draggable="false" class="emoji"></span> By clicking either check mark, you indicate that you have read and agree to
abide by the above rules and policies, and you understand that these rules and policies are not exhaustive and are subject to change.</blockquote>
</div>
<time datetime="2021-03-03T00:54:27.794Z" class="edited-3sfAzf" role="note" aria-label="Tuesday, March 2, 2021 4:54 PM">(edited)</time>
</div>
</div>
<div class="container-1ov-mD">
<div class="reactions-12N0jA" role="group" aria-label="Reactions">
<div>
<div class="reaction-1hd86g" style="opacity: 1;">
<div aria-controls="popout_1620" aria-expanded="false">
<div class="reactionInner-15NvIl" aria-label="✅, press to react" aria-pressed="false"><img src="/assets/212e30e47232be03033a87dc58edaa95.svg" alt="✅" draggable="false" class="emoji">
<div class="reactionCount-2mvXRV" style="min-width: 45px;">15271</div>
</div>
</div>
</div>
</div>
<div>
<div class="reaction-1hd86g" style="opacity: 1;">
<div aria-controls="popout_1621" aria-expanded="false">
<div class="reactionInner-15NvIl" aria-label="☑️, press to react" aria-pressed="false"><img src="/assets/86c16c39d96283551fd4ca7392e22681.svg" alt="☑️" draggable="false" class="emoji">
<div class="reactionCount-2mvXRV" style="min-width: 36px;">9731</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="buttonContainer-DHceWr">
<div class="buttons-cl5qTG container-3npvBV" aria-label="Message Actions">
<div class="wrapper-2aW0bm">
<div class="button-1ZiXG9" aria-label="More" aria-controls="popout_1627" aria-expanded="false" role="button" tabindex="0">
<svg class="icon-3Gkjwa" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24">
<path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M7 12.001C7 10.8964 6.10457 10.001 5 10.001C3.89543 10.001 3 10.8964 3 12.001C3 13.1055 3.89543 14.001 5 14.001C6.10457 14.001 7 13.1055 7 12.001ZM14 12.001C14 10.8964 13.1046 10.001 12 10.001C10.8954 10.001 10 10.8964 10 12.001C10 13.1055 10.8954 14.001 12 14.001C13.1046 14.001 14 13.1055 14 12.001ZM19 10.001C20.1046 10.001 21 10.8964 21 12.001C21 13.1055 20.1046 14.001 19 14.001C17.8954 14.001 17 13.1055 17 12.001C17 10.8964 17.8954 10.001 19 10.001Z"></path>
</svg>
</div>
</div>
</div>
</div>
</div>
<div class="divider-3_HH5L hasContent-1_DUdQ divider-JfaTT5 hasContent-1cNJDh"><span class="content-1o0f9g">June 8, 2020</span></div>
<div class="message-2qnXI6 cozyMessage-3V1Y8y groupStart-23k01U wrapper-2a6GCs cozy-3raOZG zalgo-jN1Ica" role="listitem" data-list-item-id="chat-messages___chat-messages-719650608935731211" tabindex="-1" id="chat-messages-719650608935731211">
<div class="contents-2mQqc9" role="document"><img src="https://cdn.discordapp.com/avatars/717491799014506551/7915934d00f156ee499963d2c14ecdf8.png?size=256" aria-hidden="true" class="avatar-1BDn8e clickable-1bVtEA" alt=" ">
<h2 class="header-23xsNx"><span class="headerText-3Uvj1Y"><span class="username-1A8OIy clickable-1bVtEA" aria-controls="popout_1623" aria-expanded="false" role="button" tabindex="0">nookazon</span></span><span class="timestamp-3ZCmNB"><span aria-label="06/08/2020">06/08/2020</span></span>
</h2>
<div class="markup-2BOw-j messageContent-2qWWxC"><span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":arrow_up:" src="/assets/b51c7cfe515fd884537ca5c2ac8ce7a2.svg" alt=":arrow_up:" draggable="false" class="emoji"></span> If you <strong>do not</strong> see the checkmarks
under the above message, make sure you have Reaction Emojis enabled in your Discord settings.
<div class="blockquoteContainer-U5TVEi">
<div class="blockquoteDivider-2hH8H6"></div>
<blockquote>Go to User Settings <span class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":gear:" src="/assets/a6d05968d7706183143518d96c9f066e.svg" alt=":gear:" draggable="false" class="emoji"></span> → Text & Images → Emoji
<span
class="emojiContainer-3X8SvE" role="button" tabindex="0"><img aria-label=":warning:" src="/assets/289673858e06dfa2e0e3a7ee610c3a30.svg" alt=":warning:" draggable="false" class="emoji"></span> If you are having trouble receiving full access, make sure that you have reacted to get the role. After,
<em>please wait up to 10 minutes</em> due to traffic as the bot can get overloaded. If this doesn't work, <em>restart Discord</em> (control/command R), then attempt to click on it again. If you are still having troubles, please ask in
<span
class="wrapper-3WhCwL mention interactive" tabindex="0" role="button">#❔-help</span> after you have attempted the troubleshooting methods above.</blockquote>
</div>
</div>
</div>
<div class="container-1ov-mD"></div>
</div>
<div class="scrollerSpacer-avRLaA"></div>
</div>
:last-child
伪选择器应用于它所附加的元素。在这种情况下,您选择的是最后一个.scrollerInner-XXXXX
div,它是父元素的子元素,而不是最后一个.message-XXXXX
。
但是,因为.message-XXXXX
元素不是.scrollerInner-XXXXX
元素的最后一个子元素,所以不能使用:last-child
。你必须用:last-of-type
代替。
总之,您需要查询.scrollerInner-XXXXX .message-XXXXX:last-of-type
:
document.querySelector('.scrollerInner-XXXXX .message-XXXXX:last-of-type');
这里假设.message-XXXXX
对于每条消息都是相同的。
否则,您将希望获得.scrollerInner-XXXXX
的子节点并按类名过滤它们,然后获得最后一个。
const scrollerInnerChildren = Array.from(document.querySelector('.scrollerInner-XXXXX').children);
const hasMessagesFilter = child => Array.from(child.classList).some(cl => cl.startsWith('message-'));
const childrenWithMessages = scrollerInnerChildren.filter(hasMessagesFilter);
const { length } = childrenWithMessages;
const lastMessageElement = childrenWithMessages[length - 1];