Last active
December 16, 2015 21:59
-
-
Save htsign/5503807 to your computer and use it in GitHub Desktop.
自動ログインというか、XMLファイルを軽くいじるとログインしてくれるように動くスクリプトのサンプル。
会社で自分用に使っていたのでIE6でしかテストできていません。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<?xml-stylesheet type="text/xsl" href="res/loginform.xsl"?> | |
<request to="(input here URL to send request)"> | |
<param name="mail" value="foo%40bar.com"/> | |
<param name="pass" value="this_is_password"/> | |
<param name="login" value="true"/> | |
</request> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@charset "utf-8"; | |
.warn { | |
font-weight: bold; | |
} | |
#param-sheet, | |
#param-sheet * { | |
margin: 4px; | |
padding: 2px; | |
border: 1px solid silver; | |
font-family: "MS Pゴシック", sans-serif; | |
font-size: 12px; | |
} | |
.none { | |
text-align: center; | |
border-width: 0; | |
color: gray; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | |
<xsd:element name="request"> | |
<xsd:complexType> | |
<xsd:sequence> | |
<xsd:element name="param" type="parameter" maxOccurs="unbounded"/> | |
</xsd:sequence> | |
<xsd:attribute name="to" type="xsd:anyURI" use="required"/> | |
</xsd:complexType> | |
</xsd:element> | |
<xsd:complexType name="parameter"> | |
<xsd:sequence></xsd:sequence> | |
<xsd:attribute name="name" type="xsd:string" use="required"/> | |
<xsd:attribute name="value" type="xsd:string" use="optional" default=""/> | |
</xsd:complexType> | |
</xsd:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.onload = function(){ | |
var d = document, div = d.getElementById("loggingIn"), | |
add = function(t) { return div.appendChild(d.createTextNode(t||".")) }; | |
div.className = "warn"; | |
add("ログイン中"); | |
window.setInterval(add, 100); | |
d.forms[0].submit(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output method="xml" version="1.0" encoding="utf-8" | |
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" | |
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/> | |
<xsl:template match="/request"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja"> | |
<head> | |
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/> | |
<link rel="stylesheet" type="text/css" href="res/css/default.css"/> | |
<script type="text/javascript" src="res/js/login.js"></script> | |
<title>ログイン中...</title> | |
</head> | |
<body> | |
<form> | |
<xsl:attribute name="method"> | |
<xsl:choose> | |
<xsl:when test="count(@method)!=0"> | |
<xsl:value-of select="@method"/> | |
</xsl:when> | |
<xsl:otherwise>post</xsl:otherwise> | |
</xsl:choose> | |
</xsl:attribute> | |
<xsl:attribute name="action"> | |
<xsl:value-of select="@to"/> | |
</xsl:attribute> | |
<div> | |
<xsl:for-each select="param"> | |
<input type="hidden"> | |
<xsl:attribute name="name"> | |
<xsl:value-of select="@name"/> | |
</xsl:attribute> | |
<xsl:attribute name="value"> | |
<xsl:value-of select="@value"/> | |
</xsl:attribute> | |
</input> | |
</xsl:for-each> | |
</div> | |
</form> | |
<div id="loggingIn"></div> | |
<table id="param-sheet"> | |
<tbody> | |
<tr> | |
<th>パラメータ</th> | |
<th>値</th> | |
</tr> | |
<xsl:for-each select="param"> | |
<tr> | |
<td><xsl:value-of select="@name"/></td> | |
<td> | |
<xsl:choose> | |
<xsl:when test="@name='pass' or @name='password' or @name='PASSWORD' or @name='PW'"> | |
<xsl:text>****************</xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:choose> | |
<xsl:when test="count(@value)=0 or @value=''"> | |
<xsl:attribute name="class">none</xsl:attribute> | |
<xsl:text>(none)</xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="@value"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:otherwise> | |
</xsl:choose> | |
</td> | |
</tr> | |
</xsl:for-each> | |
</tbody> | |
</table> | |
</body> | |
</html> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment