I’ve updated my WordPress plugin Widget Output Filters to version 1.1, which most notably now includes the sidebar ID in the parameters it passes to the filter.
The plugin code has been refactored, and is now also available on GitHub and as a Composer package.