This article mainly introduces how I receive 12 Roses After coding my Valentine's Day Singles' Day ticket. If you are interested, I will not talk much about the nonsense. I will show you the following:
To sum up, this article is a script for refreshing stars (in flash memory. On the Chinese Valentine's Day, it's just a rose, so it's not a title party. Let me show you the stars!
1. Send messages
View the request and send it by Simulation
$. Post ("http://ing.cnblogs.com/ajax/ing/Publish", // address JSON. stringify ({"content": content, "publicFlag": 1}), // parameter, json Format String function (result) {// callback console. log (".............. the message is sent successfully. Next, determine if there is a star. "); result & result. isSuccess & judgeStar (content)}, "json"); // convert the returned content to a js object.
Ii. Determine whether the message has just been sent is lucky
Still looking at the picture and talking.
Request URL: http://ing.cnblogs.com/ajax/ing/GetIngList? IngListType = all & PageIndex = 1 & PageSize = 30 & Tag = & _ = 1440087133884
According to the name (and indeed), you can select the type (my, my response, new response, mention me, reply to me, full site), page number, page size per page. The last one is the timestamp.
We simulate the request:
$. Ajax ({url: "http://ing.cnblogs.com/ajax/ing/GetIngList? IngListType = all & PageIndex = 1 & PageSize = 3 & Tag = & _ = "+ (+ new Date), type:" get ", dataType:" text ", success: function (result) {// processing logic
// Parse ghost Doc =doc (result); // you can see what the ghost is on the console }});
DataType: "text" is used because:
A piece of html code is returned. Using $ (result) on the console, we can see that there are three parts. We need to find the part we just sent and determine whether there is a lucky flash. I only choose to get the first three items here for determination. If more than three people have just flushed flash with me, I won't be able to find it... therefore, you can increase the number of pages.
Here is the code I found and determined whether there are stars:
Var feedDiv = $ (result ). eq (2); var msgSpan = feedDiv. find ("span: contains ('" + msg + "')"); // The search is not rigorous, especially in the evening... if (msgSpan. length> 0) {console. log (".............. locate the sent flash memory and start to judge ");} else {console. log (".............. the sent flash memory is not found. A script error may occur. ");} var id = msgSpan. attr ("id "). match (/body _ (\ d +) $/) [1]; if (msgSpan. next ("img. ing_icon_lucky "). length> 0) {console. log (".............. lucky pop + 1 [Star] ");} else {// The stars are not found. It seems that luck is not good. Delete the one you just deleted !!! }
3. Delete the star-less "waste" flash memory.
If the stars (roses) are useless, just drop them...
I will not send a picture here, so I will directly go to the Code:
// Delete the flash function delMsg (id) {console. log (".............. if no stars exist, delete the flash memory. The id is "+ id); return $. post ("http://ing.cnblogs.com/ajax/ing/del", JSON. stringify ({ingId: id }));}
Iv. Summary
Whether or not I can get the "Stars" is really related to my face. I have to brush it once every 6 minutes, and I have to brush it for more than a dozen times a night.
It's, so I'm very upset. My company keeps refreshing this script on its computer. I can't find it at home. I don't know if it will happen to be a dark house tomorrow ...... so I will stop it early tomorrow morning.
I don't know if the browser is stuck. Sometimes there are few stars, and it hasn't been deleted...
The complete code is as follows:
Function memeda (input) {var times = 0; shuaXingXing (input); function shuaXingXing (content) {sendMsg (content); setInterval (function () {sendMsg (content );}, 1000*60*6 + 100);} // sends the Flash message function sendMsg (content) {console. log ("..................................... ............................... "); times ++; console. log ("current time:" + new Date (). toLocaleTimeString () + "+" + times + ""); console. log (".............. send flash "); return $. post (" http://ing.cnblogs.com/ajax/ing/Publish ", JSON. stringify ({"content": content, "publicFlag": 1}), function () {}, "json "). done (function (result) {console. log (".............. determine whether there are stars "); result & result. isSuccess & judgeStar (content)});} // determines whether there is a star function judgeStar (msg) {$. ajax ({url :" http://ing.cnblogs.com/ajax/ing/GetIngList?IngListType=all&PageIndex=1&PageSize=3&Tag=&_= "+ (+ New Date), type:" get ", dataType:" text ", success: function (result) {var feedDiv =$ (result ). eq (2); var msgSpan = feedDiv. find ("span: contains ('" + msg + "')"); if (msgSpan. length> 0) {console. log (".............. locate the sent flash memory and start to judge ");} else {console. log (".............. the sent flash memory is not found. A script error may occur. ");} var id = msgSpan. attr ("id "). match (/body _ (\ d +) $/) [1]; if (msgSpan. next ("img. ing_icon_lucky "). length> 0) {console. log (".............. lucky flash + 1 [Star] ") ;}else {delMsg (id) ;}}) ;}// Delete the flash function delMsg (id) {console. log (".............. if no stars exist, delete the flash memory. The id is "+ id); return $. post (" http://ing.cnblogs.com/ajax/ing/del ", JSON. stringify ({ingId: id }));}}
The above is how I got 12 Roses after I typed the code on Valentine's Day. I hope everyone will like it.