我想在SAP BO" Query Builder"上运行脚本片段,它是一个使用SQL检索数据的简单工具。 (由于声誉,我无法上传图片,可以在此处找到产品的界面:http://scn.sap.com/docs/DOC-42952)
由于我要运行一堆查询,因此我想使用代码段自动运行它们。使用以下代码:
//select the textarea to insert retrieved queries
document.querySelector("textarea").textContent = "SELECT * FROM CI_INFOOBJECTS";
//click the submit button
document.getElementsByTagName('input')[0].click();
//code to export the query result
//after click(), the page reloaded and it won't executed the following code.
document.addEventListener("DOMContentLoaded", function() {
//back to the previous page, run the previous code again
window.history.back(1);
}, false);
有没有人有如何实施它的好主意?谢谢你的帮助。
答案 0 :(得分:2)
您可以将Tampermonkey用于Chrome,您可以从hibbard tampermonkey tutorial等网站了解如何使用它。 总的来说,你的sript会是这样的:
// ==UserScript==
// @name Enter any name you like here
// @namespace URL of website you own
// @version 0.1
// @description retrive data using sql
// @author Your name here
// @match relevant url
// ==/UserScript==
/* jshint -W097 */
// Your code here...
//select the textarea to insert retrieved queries
document.querySelector("textarea").textContent = "SELECT * FROM CI_INFOOBJECTS";
//click the submit button
document.getElementsByTagName('input')[0].click();
//code to export the query result
//after click(), the page reloaded and it won't executed the following code.
document.addEventListener("DOMContentLoaded", function() {
//back to the previous page, run the previous code again
window.history.back(1);
}, false);