use global/document in patch.js