How can I inject html after the [x]th widget inside a Sidebar? [duplicate]

If I’m understanding you correctly, a dirty way to achieve this would be to use 2 sidebar areas on the page: an upper and lower. Call the upper, then include your code, then call the lower.

Other ways might be to create your own widget that pulls in the appropriate data at runtime, but you haven’t explained the “programmatically created” part of your requirement.