저는 Javascript와 Greasemonkey에 완전히 익숙하지 않습니다. 비효율적이거나 잘못 수행하면 저를 바로 잡으십시오.동적 양식을 표의 끝에 추가하려면 어떻게합니까?
내가 게시하는이 포럼에서 "답장"버튼을 클릭하면 게시 할 텍스트 양식이있는 새로운 창이 열립니다. 응답 양식의 스크립트를 실제 스레드에 추가하는 그리스 몽키 스크립트를 만들고 싶습니다. 페이지.
그래서 프로그램은 토론을 저장하는 테이블을 통과하여 테이블 끝 부분에 childNode를 추가합니다. 그 childNode가 응답 페이지에서 작성된 양식이되기를 원합니다.
// ==UserScript==
// @name QuickEeply
// @namespace http://userscripts.org/users/181447
// @description Adds "QuickReply" forms to TCC discussion posts
// @include *
// ==/UserScript==
var tables = document.getElementsByTagName("td");
for (var i = 0; i < tables.length; i++) {
if (tables[i].className == "content")
{ var editTable = tables[i];
}
}
editTable.appendChild = ''
여기에 복사하고 "응답 페이지"에서 붙여 넣은 스크립트의
<form method="POST" action="http://dl.tccd.edu/index.php/classforums/posts/event=saveReply">
<input type="hidden" name="subject" size="45" id="txt_subject" maxlength="200" value="">
<br>
Message:<br>
<textarea rows="20" style="width:70%;" name="message" id="message"></textarea>
<br>
<br>
<input type="submit" id="submit_post" value="Post Reply">
<input type="hidden" name="post_id" value="1010815">
<input type="hidden" name="thread_id" value="1010815">
</form>
그래서 어떻게 스크립트를 만드는 방법에 대해 갈 수 있습니다 : 여기
내 스크립트의 골격이다 이 함수는 현재 페이지의 thread_id를 찾고 스레드가 실제로 위치한 페이지의 각 페이지에 대한 replybox를 만듭니다.편집 : 다음은 소스 코드 -
http://pastebin.com/2UaUVGJA (주 토론 페이지)
http://pastebin.com/hAx2SPUu (응답 페이지)
편집 2 :
I've used Brock's template, and it's not working. What do I need to do to correct it?
// ==UserScript==
// @name Quick_ReplyTest
// @namespace http://userscripts.org/users/181447
// @description Inserts QuickReply
// @include *
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// ==/UserScript==
/* Optional:
window.addEventListener ("load", Greasemonkey_main, false);
*/
$(document).ready (Greasemonkey_main);
function Greasemonkey_main()
{
/*--- Get the first node inside the id="main" span (Google.com)
If that's not there, then get the first node of the html body.
*/
var TargetNode = $("a[href*='event=reply/post']");
if (!TargetNode)
TargetNode = $("body *:first");
$(TargetNode).after
(
"<form method="POST" action="http://dl.tccd.edu/index.php/classforums/posts/event=saveReply">
+ "<input type="hidden" name="subject" size="45" id="txt_subject" maxlength="200" value="">"
+ "<br> Message:<br>"
+ "<textarea rows="20" style="width:70%;" name="message" id="message"></textarea>"
+ "<br> <br>"
+ "<input type="submit" id="submit_post" value="Post Reply">"
+ "<input type="hidden" name="post_id" value="1010815">"
+"<input type="hidden" name="thread_id" value="1010815">"
+"</form>"
);
}
당신이보고있는 HTML을 보지 않고 말하기 힘든 종류입니다. Post ID와 Thread ID 변수를 사용할 수 있습니까? – desau
소스 코드를 포함하도록 편집했습니다. – Parseltongue