<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.explainxkcd.com/wiki/index.php?action=history&amp;feed=atom&amp;title=explain_xkcd%3ACrap</id>
		<title>explain xkcd:Crap - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://www.explainxkcd.com/wiki/index.php?action=history&amp;feed=atom&amp;title=explain_xkcd%3ACrap"/>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=explain_xkcd:Crap&amp;action=history"/>
		<updated>2026-06-17T04:09:38Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=explain_xkcd:Crap&amp;diff=376056&amp;oldid=prev</id>
		<title>FaviFake: /* Anti-re-crapping code */</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=explain_xkcd:Crap&amp;diff=376056&amp;oldid=prev"/>
				<updated>2025-05-02T07:55:04Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Anti-re-crapping code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 07:55, 2 May 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l35&quot; &gt;Line 35:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 35:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Anti-re-crapping code==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Anti-re-crapping code==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Most pre-block efforts at stopping the vandalism involved the line of code in the bot that checked if the page had already been crapped and skipped over it if it had (the first &amp;lt;code&amp;gt;else if&amp;lt;/code&amp;gt; line). Originally, this line looked something like the following: &amp;lt;code&amp;gt;} else if (document.querySelector(cssSelectorForMainContent).textContent.startsWith('crap')) {&amp;lt;/code&amp;gt; This line allowed a page to be easily protected by adding the following code at the start of the page: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;div style=&amp;quot;display: none&amp;quot;&amp;gt;crap&amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. This added the word &amp;quot;crap&amp;quot; to the page in a way that the bot could see but readers could not, non-disruptively preventing the page from being crapped. The vandal later changed the line to &amp;lt;code&amp;gt;} else if (document.querySelector(cssSelectorForMainContent).textContent.startsWith('crap crap')) {&amp;lt;/code&amp;gt; to bypass the anti-crap code, but this was easily thwarted by changing the protection code to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;div style=&amp;quot;display: none&amp;quot;&amp;gt;crap crap&amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. The final version of the bot (shown in the main code block above) checked for crappedness by seeing if the text contained a lowercase &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;; if it contained a &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt; it was known to be uncrapped (and in need of crapping, according to the vandal); if it did not contain a &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;, it was assumed to have already been crapped. This worked very &amp;quot;well,&amp;quot; because the word &amp;quot;crap&amp;quot; does not contain a &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;, but the vast majority of uncrapped articles do. With this code, a page could only be protected by removing all &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;'s, which is not feasible for the vast majority of pages.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;{{citation needed}} &lt;/del&gt;After this change, the only way to hinder the bot (until it was blocked by an admin) was to revert its edits as fast as possible.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Most pre-block efforts at stopping the vandalism involved the line of code in the bot that checked if the page had already been crapped and skipped over it if it had (the first &amp;lt;code&amp;gt;else if&amp;lt;/code&amp;gt; line). Originally, this line looked something like the following: &amp;lt;code&amp;gt;} else if (document.querySelector(cssSelectorForMainContent).textContent.startsWith('crap')) {&amp;lt;/code&amp;gt; This line allowed a page to be easily protected by adding the following code at the start of the page: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;div style=&amp;quot;display: none&amp;quot;&amp;gt;crap&amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. This added the word &amp;quot;crap&amp;quot; to the page in a way that the bot could see but readers could not, non-disruptively preventing the page from being crapped. The vandal later changed the line to &amp;lt;code&amp;gt;} else if (document.querySelector(cssSelectorForMainContent).textContent.startsWith('crap crap')) {&amp;lt;/code&amp;gt; to bypass the anti-crap code, but this was easily thwarted by changing the protection code to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;div style=&amp;quot;display: none&amp;quot;&amp;gt;crap crap&amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. The final version of the bot (shown in the main code block above) checked for crappedness by seeing if the text contained a lowercase &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;; if it contained a &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt; it was known to be uncrapped (and in need of crapping, according to the vandal); if it did not contain a &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;, it was assumed to have already been crapped. This worked very &amp;quot;well,&amp;quot; because the word &amp;quot;crap&amp;quot; does not contain a &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;, but the vast majority of uncrapped articles do. With this code, a page could only be protected by removing all &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;'s, which is not feasible for the vast majority of pages. After this change, the only way to hinder the bot (until it was blocked by an admin) was to revert its edits as fast as possible.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The wiki's [[MediaWiki:Common.js]] now prevents edits which set a large portion of the article to a single repeated word.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The wiki's [[MediaWiki:Common.js]] now prevents edits which set a large portion of the article to a single repeated word.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>FaviFake</name></author>	</entry>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=explain_xkcd:Crap&amp;diff=376055&amp;oldid=prev</id>
		<title>FaviFake: I think this needs to be documented somewhere. Made several improvements</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=explain_xkcd:Crap&amp;diff=376055&amp;oldid=prev"/>
				<updated>2025-05-02T07:54:23Z</updated>
		
		<summary type="html">&lt;p&gt;I think this needs to be documented somewhere. Made several improvements&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The 'crap' incident&lt;br /&gt;
On May 3rd, 2022, a vandal started attacking the wiki with a bot that replaced entire pages with the word &amp;quot;crap&amp;quot; repeated several thousand times. Many discussions [[explain xkcd talk:Community portal/Admin requests#User vandalizing rapidly|were created in the &amp;quot;Admin requests&amp;quot; portal]] to organise the cleanup of the wiki until the vandal was stopped by [[User:Davidy22|Davidy22]].&lt;br /&gt;
&lt;br /&gt;
==Original code==&lt;br /&gt;
It initially used the account [[Special:Contributions/X. K. C. D.|X. K. C. D.]], which had previously been used for vandalism but was never blocked. The account was old enough, and had made enough edits, to be autoconfirmed, allowing it to edit pages without having to complete CAPTCHAs. Several accounts have been identified and blocked since, some after becoming autoconfirmed and running the bot script. The bot is implemented as a user &amp;lt;code&amp;gt;common.js&amp;lt;/code&amp;gt; JavaScript page that has had several versions, some obfuscated. One such script is below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var cssSelectorForEditTextBox = 'textarea'&lt;br /&gt;
var cssSelectorForSaveChangesButton = '#wpSave'&lt;br /&gt;
var cssSelectorForMainContent = '#mw-content-text'&lt;br /&gt;
var cssSelectorForEditLink = '#ca-edit &amp;gt; span:nth-child(1) &amp;gt; a:nth-child(1)'&lt;br /&gt;
&lt;br /&gt;
function vandalize() {&lt;br /&gt;
    if (window.location.href.endsWith('edit')) {&lt;br /&gt;
        // The current page is an &amp;quot;edit&amp;quot; page&lt;br /&gt;
        // Crap it&lt;br /&gt;
        document.querySelector(cssSelectorForEditTextBox).value = 'crap '.repeat(5000);&lt;br /&gt;
        document.querySelector(cssSelectorForSaveChangesButton).click()&lt;br /&gt;
    } else if (document.querySelector(cssSelectorForMainContent).textContent.indexOf('t') == -1) {&lt;br /&gt;
        // The current page is a regular &amp;quot;read&amp;quot; page, but it has already been crapped&lt;br /&gt;
        // Go to a random uncrapped page&lt;br /&gt;
        window.location.href = 'https://www.explainxkcd.com/wiki/index.php/Special:RandomInCategory/All_Comics'&lt;br /&gt;
    } else {&lt;br /&gt;
        // The current page is a regular &amp;quot;read&amp;quot; page, and it has not yet been crapped&lt;br /&gt;
        // Go to its &amp;quot;edit&amp;quot; page so it can be crapped&lt;br /&gt;
        document.querySelector(cssSelectorForEditLink).click()&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
setTimeout(vandalize, 500);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While this code is a reconstruction of the original code, it has been tested (non-destructively) and found to be equivalent in functionality. Other than the CSS selectors, it was mostly rewritten from memory by a contributor who had read the original &amp;lt;code&amp;gt;common.js&amp;lt;/code&amp;gt; file. (That file has since been deleted.) The CSS selectors are educated guesses, but they seem to be equivalent to the original ones. Also, the code has been reformatted for readability; the original had everything on two or three lines, had the CSS selectors inline with the rest of the code (rather than in variables), and had no comments. Newer versions appear to be based on this reconstructed code, rather than the original. It is not clear why the crapper did this.&lt;br /&gt;
&lt;br /&gt;
By the time the original bot was blocked, about 80% of comic explanations had been crapped. [[User:Davidy22|Davidy22]] blocked the bot and deleted its &amp;lt;code&amp;gt;common.js&amp;lt;/code&amp;gt; page; this immediately stopped the vandalism attack and allowed the cleanup to begin. Later attacks/recoveries have followed this same pattern, except administrators have responded faster, reducing the number of pages crapped in each attack.&lt;br /&gt;
&lt;br /&gt;
==Anti-re-crapping code==&lt;br /&gt;
Most pre-block efforts at stopping the vandalism involved the line of code in the bot that checked if the page had already been crapped and skipped over it if it had (the first &amp;lt;code&amp;gt;else if&amp;lt;/code&amp;gt; line). Originally, this line looked something like the following: &amp;lt;code&amp;gt;} else if (document.querySelector(cssSelectorForMainContent).textContent.startsWith('crap')) {&amp;lt;/code&amp;gt; This line allowed a page to be easily protected by adding the following code at the start of the page: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;div style=&amp;quot;display: none&amp;quot;&amp;gt;crap&amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. This added the word &amp;quot;crap&amp;quot; to the page in a way that the bot could see but readers could not, non-disruptively preventing the page from being crapped. The vandal later changed the line to &amp;lt;code&amp;gt;} else if (document.querySelector(cssSelectorForMainContent).textContent.startsWith('crap crap')) {&amp;lt;/code&amp;gt; to bypass the anti-crap code, but this was easily thwarted by changing the protection code to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;div style=&amp;quot;display: none&amp;quot;&amp;gt;crap crap&amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. The final version of the bot (shown in the main code block above) checked for crappedness by seeing if the text contained a lowercase &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;; if it contained a &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt; it was known to be uncrapped (and in need of crapping, according to the vandal); if it did not contain a &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;, it was assumed to have already been crapped. This worked very &amp;quot;well,&amp;quot; because the word &amp;quot;crap&amp;quot; does not contain a &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;, but the vast majority of uncrapped articles do. With this code, a page could only be protected by removing all &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;'s, which is not feasible for the vast majority of pages.{{citation needed}} After this change, the only way to hinder the bot (until it was blocked by an admin) was to revert its edits as fast as possible.&lt;br /&gt;
&lt;br /&gt;
The wiki's [[MediaWiki:Common.js]] now prevents edits which set a large portion of the article to a single repeated word.&lt;br /&gt;
&lt;br /&gt;
==Other &amp;quot;improvements&amp;quot;==&lt;br /&gt;
The vandal changed the delay after page load (the number in the last line; 500 in the last version with a delay) several times, before changing it to load with &amp;lt;code&amp;gt;document.body.onload&amp;lt;/code&amp;gt;, then finally removing the wrapper and making it run as soon as the JavaScript loads.&lt;br /&gt;
&lt;br /&gt;
The code was briefly obfuscated, then de-obfuscated after it crapped itself. The only functional difference was checking for a lowercase 'e' instead of a 't'.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
In the end, the admin [[User:Davidy22|Davidy22]] [https://www.reddit.com/r/xkcd/comments/uhtikr/comment/i78lhe6 came back from Reddit] to block the vandalising accounts, remove the script, and revert the changes.&lt;/div&gt;</summary>
		<author><name>FaviFake</name></author>	</entry>

	</feed>