这是我的项目中的问题,这是一个文本"时间在"输入后,脚本将被执行,第三方网站将由if块填写。如果您希望我提供更多详细信息,请告诉我您需要哪些具体细节,请在下面发表评论。
function MessageHandler(context, event) {
//context.console.log("test")
var x = event.message.toLowerCase();
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
if (minutes < 10){
minutes = "0" + minutes
}
if(hours > 11){
z = "AM";
} else {
z = "PM";
}
w = (hours + 8 + ":" + minutes + " " + z);
if(x.startsWith("time in")) {
context.sendResponse("timed in at " + w);
var desc = "BOT TIME IN";
var proj = "Koodi - Training"; //just in case value doesn't work, try: var proj = 5;(this is for me)
var tick = "15"; //put random number in testing.
/*i want here the code that will make the data to be inserted in the fields of the 3rd party website(http://timebound.dev2.koodi.ph/timer)
these are the fields of the 3rd party website which i want the date to be filled:
<input placeholder="What are you working on?" id="timer-desc" tabindex="1" name="description" type="text">
<select tabindex="-1" id="timer-project" name="project_id" class="select2-hidden-accessible" aria-hidden="true">
<option value="5">Koodi - Training</option>
<option value="19">Koodi Marketing</option>
<option value="6">Koodi Site</option>
<option value="2">Wisebread - D6</option>
</select>
<input placeholder="Ticket reference" tabindex="3" id="timer-ticket" name="ticket" type="text">
Lastly, I want this button to be clicked(automatically of course) after the fields are filled.
<input class="btn btn-default btn-primary" id="timer-btn" type="submit" value="Start">
*/
}
答案 0 :(得分:0)
您似乎正在尝试使用脚本自动填充详细信息。在这种情况下,检查其他网站,看看输入字段是否有任何ID /名称等。然后您可以使用JS API,如getElementById / getElementsByName等来获取确切的输入字段。发布您可以设置所需的数据。
类似地,您可以获取按钮实例并调用单击它。如果您坚持任何特定点,请告诉我们。
我认为您不能直接在该网站上注入您的JS代码,以便您的代码适用于所有人(除非您发现安全漏洞)!您可以加载该网站,按F12(在Chrome中)打开调试器,然后执行脚本。