我希望做一個Chrome擴展..我想一個選項頁面,您提交的關鍵字:HTML中進入的Javascript
<html>
<head>
<title>Options</title>
</head>
<body>
Keyword:<input id="keyText" name="Keyword" type="text">
<input name="Submit" type="submit" value="Submit">
</body>
</html>
這個JavaScript應該刷新微博,直到它找到一個關鍵詞然後點擊推文中的鏈接。 我想放在這個提交的關鍵字到Java腳本插入到第一VAR:
var shoeName = "";
var nikestore = "nikestore";
var closeFlag = "no";
var tFunction = "twitterScan()";
var tweet = new Array();
var tweetName = new Array();
function twitterScan() {
for (var i = 0; i < 4; i++) {
tweetName[i] = document.getElementsByClassName("fullname js-action-profile-name show-popup-with-id")[0].innerHTML;
tweet[i] = document.getElementsByClassName("js-tweet-text")[i].innerHTML;
}
//if (document.getElementsByClassName("fullname js-action-profile-name show-popup-with-id")[0].innerHTML;
if (tweet[0].match(shoeName) == shoeName) {
document.getElementsByClassName("twitter-timeline-link")[0].click();
tFunction = "get outa here";
shoeName = " 4444 4 456 7 8 456 7 345 7 345 345 3 1 1 133s "; //buffer to jump out of interval loop
}
else if (tweet[1].match(shoeName) == shoeName) {
document.getElementsByClassName("twitter-timeline-link")[1].click();
tFunction = "get outa here";
shoeName = " 4444 4 456 7 8 456 7 345 7 345 345 3 1 1 133s "; //buffer to jump out of interval loop
}
else if (tweet[2].match(shoeName) == shoeName) {
document.getElementsByClassName("twitter-timeline-link")[2].click();
tFunction = "get outa here";
shoeName = " 4444 4 456 7 8 456 7 345 7 345 345 3 1 1 133s "; //buffer to jump out of interval loop
}
else if (tweet[3].match(shoeName) == shoeName) {
document.getElementsByClassName("twitter-timeline-link")[3].click();
tFunction = "get outa here";
shoeName = " 4444 4 456 7 8 456 7 345 7 345 345 3 1 1 133s "; //buffer to jump out of interval loop
}
else {
location.reload(true);
}
setTimeout(tFunction, 700);
}
setTimeout(tFunction, 700);
//setInterval("refreshPage()", 3000);
//setTimeout("twitterScan()", 100);
//setInterval(tFunction, 700);
html發佈完成了嗎?你目前面臨的問題是什麼?是可變數據不會來或某些功能行爲不當? –
我想在html中提交的關鍵字被設置爲java腳本中的var shoeName – user2125877
@ user2125877:我不確定爲什麼'document.getElementById('ketText')。val'不能在你的情況下工作,你能創建一個jsfiddle,http://jsfiddle.net,將檢查它 – dreamweiver