Skip to content

Instantly share code, notes, and snippets.

/bug report Secret

Created November 16, 2011 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/124b97bf4b7684af203f to your computer and use it in GitHub Desktop.
Save anonymous/124b97bf4b7684af203f to your computer and use it in GitHub Desktop.
Greasemonkey 0.9.13 bug report
// ==UserScript==
// @name test
// @namespace http://www.ccsmax.com/test.html
// @description Test for gm 9.13
// @include http://www.ccsmax.com/test.html
// ==/UserScript==
/*
This function gets called when the login submit event is received.
*/
function newLoginSubmit(event)
{
GM_xmlhttpRequest(
{
method: 'POST',
url: "http://www.ccsmax.com/max/connect",
headers:
{
'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey/0.3',
'Accept': 'text/plain',
'Content-type': 'application/x-www-form-urlencoded',
},
data: "",
onload: function(responseDetails)
{
/*
This is not being called in 9.13 - works in 9.12
*/
alert( "OK! " );
},
onerror: function(responseDetails)
{
/*
This gets called in 9.13 instead.
*/
alert( "FAILED!" );
}
});
}
var xpath_result = document.evaluate( "//form[@name='aspnetForm']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null );
if ( xpath_result != null && xpath_result.singleNodeValue != null )
{
var node = xpath_result.singleNodeValue;
//node.addEventListener( "submit", newLoginSubmit, true );
window.addEventListener( "submit", newLoginSubmit, true );
}
<html>
<head>
<title>test</title>
<script type="text/javascript" language="javascript">
function WebForm_OnSubmit()
{
return true;
}
</script>
</head>
<body>
<form name="aspnetForm" method="post" action="/max/upload" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;
}
function post_it()
{
console.log( "pre org document submit" );
theForm.submit();
console.log( "post org document submit" );
}
//]]>
</script>
<input type="submit" name="ctl01$mHolder$CmdLogin" value=" Login " onclick="javascript:post_it()" id="ctl01_mHolder_CmdLogin" />
</FORM>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment