В определенном форуме нажатие кнопки ответа порождает новое окно с текстовой формой для ввода ответа. Я хочу реализовать скрипт для создания этой конкретной текстовой формы на главной странице (вместо того, чтобы создавать новое окно). Как бы я поступил так?
Вот исходный код страниц, на которых я хочу реализовать скрипт:
http://pastebin.com/2UaUVGJA (главная страница обсуждения)
http://pastebin.com/hAx2SPUu (страница ответа)
Вот попытка скрипта (обратите внимание, что мне все еще нужен какой-то метод для извлечения соответствующего значения post_id и создания формы на основе этого Id), который не работает вообще.
// ==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> \
'
);
}