/
/
=
=
UserScript
=
=
/
/
@name kanxue refresh token
/
/
@namespace http:
/
/
tampermonkey.net
/
/
/
@version
0.1
/
/
@description kanxue refresh token
/
/
@author You
/
/
@match https:
/
/
bbs.kanxue.com
/
*
/
/
@icon data:image
/
gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw
=
=
/
/
@grant none
/
/
=
=
/
UserScript
=
=
var jQuery
=
window.jQuery;
function RefreshToken(){
var csrftoken
=
jQuery(
'meta[name="csrf-token"]'
).attr(
'content'
);
var xmlhttp
=
new XMLHttpRequest();
xmlhttp.onreadystatechange
=
function() {
if
(xmlhttp.readyState
=
=
XMLHttpRequest.DONE) {
if
(xmlhttp.status
=
=
200
) {
var response
=
jQuery(xmlhttp.responseText);
var $csrfMeta
=
response.
filter
(
'meta[name="csrf-token"]'
);
var new_csrftoken
=
$csrfMeta.attr(
'content'
);
jQuery(
'meta[name="csrf-token"]'
).attr(
'content'
, new_csrftoken);
}
else
if
(xmlhttp.status
=
=
400
) {
alert(
'There was an error 400'
);
}
else
{
alert(
'something else other than 200 was returned'
);
}
}
};
xmlhttp.
open
(
"GET"
, location.href, false);
xmlhttp.send();
}
(function() {
'use strict'
;
var array
=
[
".favorite"
,
".thumb"
,
".follow_btn"
];
for
(var i
=
0
; i < array.length; i
+
+
){
jQuery(array[i]).on(
'click'
, function(event) {
RefreshToken();
})
for
(var j
=
0
; j < jQuery(array[i]).length; j
+
+
){
var eventList
=
jQuery._data(jQuery(array[i])[j],
"events"
);
eventList.click.unshift(eventList.click.pop());
}
}
})();