FF下测试通过- // ==UserScript==
- // @name Automatic update signature
- // @description 自动更新签名
- // @author wusir
- //loc.193.gs/*
- // @version 2.2
- // ==/UserScript==
- (function(){
- var href = window.location.href;
-
- function matchNode(xpath, context)
- {
- return document.evaluate(context?(xpath.indexOf('.')==0?xpath:'.' + xpath):xpath, context || document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
- }
-
- //*
- if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported")>-1))
- {
- this.GM_getValue = function (key,def) {
- return localStorage[key] || def;
- };
- this.GM_setValue = function (key,value) {
- return localStorage[key]=value;
- };
- this.GM_deleteValue = function (key) {
- return delete localStorage[key];
- };
- }
- //*/
-
- var updateTime = GM_getValue('updateTime',new Date().getTime());//最后更新时间
- var intervalTime = 1*60*1000;//更新间隔时间
- var nowTime = new Date().getTime();//现在时间
- var sIndex = GM_getValue('sIndex', 0);
- //loc.193.gs/memcp.php?action=profile&typeid=4";
- var memcp = "http://loc.193.gs/home.php?mod=spacecp&ac=profile&op=info";
- var formhash = '';
- var idcard = '';
- var address = '';
- var zipcode= '';
- var site = '';
- var bio = '';
- var interest = '';
- var customstatus = '';
- var sightml = '';
- var timeoffset = '';
- var signature = new Array();//签名设置数组
- signature[0] = '[color=red][size=5]10分钟邮箱:BccTo.Me[/size][/color]';
- signature[1] = '广告位出租';
- signature[2] = '自动签名1';
- signature[3] = '自动签名2';
- signature[4] = '自动签名3';
- GM_log('updateTime:' + updateTime);
- GM_log('nowTime:' + nowTime);
- if(nowTime - updateTime >= intervalTime)
- {
- GM_log('nowTime - updateTime = ' + (nowTime - updateTime));
- updateSignature();
- }
- else
- {
- var time = intervalTime - (nowTime - updateTime);
- GM_log('Time=' + time);
- if(time < 0)
- time = 0;
- setTimeout(updateSignature, time);
- }
- //updateSignature();//for test
- function updateSignature()
- {
- GM_log('update start');
- GM_xmlhttpRequest({
- method: 'GET',
- url: memcp,
- overrideMimeType: 'text/xml; charset=utf-8',
- onreadystatechange: function(resp){
- if(resp.readyState == 4)
- {
- if (resp.status == 200)
- {
- var text = resp.responseText;
- //GM_log(text);
- var tm = '';
- if(tm = text.match(/<input type="hidden" value="(.+?)" name="formhash" \/>/))
- formhash = tm[1];
- if(tm = text.match(/<input type="text" name="idcard" class="px" value="(.+?)" tabindex="1" \/>/))
- idcard = tm[1];
- if(tm = text.match(/<input type="text" name="address" class="px" value="(.+?)" tabindex="1" \/>/))
- address = tm[1];
- if(tm = text.match(/<input type="text" name="zipcode" class="px" value="(.+?)" tabindex="1" \/>/))
- zipcode = tm[1];
- if(tm = text.match(/<input type="text" name="site" class="px" value="(.+?)" tabindex="1" \/>/))
- site = tm[1];
- if(tm = text.match(/<textarea name="bio" id="bio".+?>(.+?)<\/textarea>/))
- bio = tm[1];
- if(tm = text.match(/<textarea name="interest" id="interest" class="pt" rows="3" cols="40" tabindex="1">(.+?)<\/textarea>/))
- interest = tm[1];
- if(tm = text.match(/<input type="text" value="(.+?)" name="customstatus" id="customstatus" class="px" \/>/))
- customstatus = tm[1];
- if(tm = text.match(/<textarea rows="3" cols="80" name="sightml" id="sightmlmessage" class="pt".+?>(.+?)<\/textarea>/))
- sightml = tm[1];
- /*
- var signnew = signature[0];
- for(var i = 0; i < signature.length; i++)
- {
- var sign = signature[i];
- if(sign == sightml)
- {
- if(i + 1 >= signature.length)
- signnew = signature[0];
- else
- signnew = signature[i + 1];
- break;
- }
- }
- */
- var signnew = signature[sIndex];
- if(parseInt(sIndex) + 1 >= signature.length)
- {
- sIndex = 0;
- GM_setValue('sIndex', 0);
- }
- else
- {
- sIndex++;
- GM_setValue('sIndex', sIndex);
- }
- var datastr = "formhash=" + formhash + "&idcardtype=身份证&privacy[idcardtype]=0&idcard=" + idcard + "&privacy[idcard]=0&address=" + address + "&privacy[address]=0&zipcode=" + zipcode + "&privacy[zipcode]=0&site=" + site + "&privacy[site]=0&bio=" + bio + "&privacy[bio]=0&interest=" + interest + "&privacy[interest]=0&customstatus=" + customstatus + "&sightml=" + signnew + "&timeoffset=9999&profilesubmit=true&profilesubmitbtn=true";
- GM_log('str:' + datastr);
- GM_xmlhttpRequest({
- method: "POST",
- url: memcp,
- data: datastr,
- headers: {'Content-type': 'application/x-www-form-urlencoded'},
- onload: function(resp) {
- var text = resp.responseText;
- GM_log('update successfully');
- //GM_log(text);
- if(text.indexOf('parent.show_success(\'\')') > -1)
- GM_setValue('updateTime',new Date().getTime());
- setTimeout(updateSignature, intervalTime);
- }
- });
- }
- }
- },
- onerror: function(){
- return;
- }
- });
- }
- })();
复制代码 |