New version of the script working correctly in AutomatorTest.
Time to test it in Mediawiki.