Get query string from Mediawiki page
Is there any way (like an undocumented magic word perhaps) to get the current query string (or full URL including query string) from within a Mediawiki template or Scribunto (Lua) module?
If this is an option, consider obtaining HTML content with API. This should be simpler than writing an extension. Of course this won't be a regular page, rather something composed client-side on blank article or server-side on non-wiki site. With Labeled Section Transclusion extension you mentioned this should work.
Alternatively, consider some server-side post processing on generated HTML. It should perform quite well as MediaWiki caches a lot.
AFAIK there is no magic word for checking query string and, IMO, this would be a very bad thing. Article source is like a model in MVC pattern — you shouldn't put presentation stuff there.