GM:直接/点击按钮打开新窗口的差异

时间:2016-05-16 08:48:49

标签: greasemonkey

首先,我不知道我在做什么,其次我希望我的英语非常好。 我最喜欢的网站最近改变了它的外观和感觉,因此我尝试通过Greasemonkey恢复“旧”风格。到目前为止一切正常但我有一个问题打开一个评论窗口。此注释(字段)现在是站点本身的一部分,并且没有自由浮动窗口。 我做的是将其添加到脚本中:

var newWin = open('','write a comment','height=300,width=600');
newWin.document.write('<html><head><title>Write a comment</title></head></head><body bgcolor="#555555" text="#000000" topmargin="0" leftmargin="0" style="overflow:hidden;"><form id="commentForm" name="photoComment" action="http://[...]/add_photo_comment/38060403" method="post"reloadUrl="[...]/photo-comments/38060403/de/page/1"data-ua-submit="Fotodetailseite;Kommentar verfassen;Foto;38060403"><div class="media-left"><div class="media-body"><div class="form_row"><textarea id="photoComment_comment" name="photoComment[comment]" required="required" rows="5" class="form-control write-comment" placeholder="Anmerkung"></textarea></div><div class="row fcx-space-tiny"><div class="col-lg-12 text-right"><button type="submit" class="btn btn-primary btn-sm submit-comment"><i class="icon icon-comment"></i>send</button></div></div></div></html>');

Sofar当我将代码直接插入脚本时(直接进入网站时会打开窗口),这对我有用。

至于我将它包装在一个函数中,新窗口将被打开,但没有反对意见:

var input=document.createElement("input");
input.type="button";
input.value="Anmerkung";
input.onclick = createComment;
input.setAttribute("style", "font-size:18px;position:absolute;top:80px;left:40px;");
document.body.appendChild(input); 

function createComment()
{
[exactly the same script as above]
};

我做错了什么? 谢谢你的帮助

0 个答案:

没有答案