The Terms of Service is a contract between the web site and the user. So by publishing a tool for others to use, you are not violating the ToS, since you are not a party to that contract. But if you use the tool yourself, a lawyer could argue that you are violating the term "Subscriber may not.. modify,.. create derivative works based on.. any of the content" from http://stackexchange.com/legal:
The Network is protected by copyright as a collective work and/or
compilation, pursuant to U.S. copyright laws, international
conventions, and other copyright laws. Other than as expressly set
forth in this Agreement, Subscriber may not copy, modify, publish,
transmit, upload, participate in the transfer or sale of, reproduce
(except as provided in this Section), create derivative works based
on, distribute, perform, display, or in any way exploit, any of the
Content, software, materials, or Services in whole or in part.
This is fundamentally the same argument over the "adblockers" - is it a ToS violation to alter copyrighted content (or alter the rendering of content, if you see the distinction) without an explicit authorisation? , Some people think it might be, some people not, there is a more detailed discussion on the Adblock forum: Violation of Google ToS?
You were not intending to strip any adverts, but the legal principle is the same, and in this case the Canonical header actually includes a registered trademark (Ubuntu). Deliberately stripping content that includes a trademark would be seen by a court as more serious than just stripping regular content.
In practice, there is no applicable case law on this. In reality, altering content on AskUbuntu is such a tiny issue that nobody is going to take you to court over it. At most, someone might ask you to stop distributing your script, but IMHO nobody would even care enough to do that, and it would be hard to justify under the ToS given that similar content modifying client-side scripts have previously been published and are still distributed by StackExchange (eg. the Greasemonkey Ignore Users script).