Fix context issue with use of `this` in add_widget_script