Tips in the blog garden-mandatory recommendations & mandatory attention (for learning and communication only)

Source: Internet
Author: User

First of all, thank you for your suggestion for this article. Although you may not have any, I have kindly helped you. Believe it? Let's take a look at the number of recommendations in the lower-right corner of the article, and refresh the page.

Next, let me talk about the implementation principle. In fact, there is no technical content. Anyone who understands javascript can perform operations.

I first checked the DOM of the Recommendation button on the page with firebug and found that it was actually a click event:

It is a method called DiggIt (). Three parameters are input respectively. The parameter names should be respectively the Article ID, blog ID, and 1 written to death. This is simple. Can I write exactly the same sentence at the bottom of the page?

So I found the input basket at the end of the page in "Settings" in the background and called this method as follows:

I was delighted to go to the test and found that the test failed. After I updated the background settings, I went back to the test and found that the entire method was not filtered out. I had no choice but to proceed with the second plan, find this method, and finally I am in the common. find this method in js as follows:

Function DiggIt (entryId, blogId, diggType) {currentDiggEntryId = entryId; var diggedType = currentDiggType; if (diggedType = 0) {ShowDiggMsg ('submitting... '); currentDiggType = diggType; AjaxPost ("/ws/digg. asmx/digg ", '{entryId:' + entryId + ', blogId:' + blogId + ', diggType:' + diggType + '}', OnDiggSuccess );} else if (diggedType = 1) {ShowDiggMsg ('You have already recommended it! ');} Else if (diggedType = 2) {ShowDiggMsg (' You have opposed it! ');}}

Of course, I don't need that much. I just need this code: AjaxPost ("/ws/digg. asmx/digg ", '{entryId:' + entryId + ', blogId:' + blogId + ', diggType:' + diggType + '}', OnDiggSuccess );

So I manually replaced some of the parameters and finally changed them to: AjaxPost ("/ws/digg. asmx/digg ", '{entryId:' + cb_entryId + ', blogId:' + cb_blogId + ', diggType: 1}', OnDiggSuccess );

Then I copied it to the HTML code of the footer. After updating the code, I found that it was still filtered out.

I started to observe this code. Generally, the filter code is filtered by string. It is automatically filtered out as long as there are any strings on the page. I think, if we split the string and splice it with "+", can we filter it out? So the code becomes: AjaxPost ("/ws/di" + "gg. as "+" mx/di "+" gg ", '{ent' + 'ryid: '+ cb_entryId +', blog '+ 'id:' + cb_blogId + ', digg' + 'ty '+ 'pe: 1}', OnDiggSuccess );

Update: I found it okay. The update was successful. I tried it in the previous blog!

Finally, in order to ensure stability, I made a layer of jquery ready method out to ensure that it will be executed after all the pages are loaded. The final code is:

$().ready(function(){    AjaxPost("/ws/di"+"gg.as"+"mx/di"+"gg", '{ent'+'ryId:' + cb_entryId + ',blog'+'Id:' + cb_blogId + ',digg'+'Ty'+'pe:1}', OnDiggSuccess);});

Now, the article is over. I only use it for study and research. Do not use it for commercial purposes. Otherwise, the consequences will be borne by me.

PS: there is a slight bug, that is, it cannot be updated immediately after submission. You need to refresh the page to see it.

PS2: in fact, the Force message function can be implemented through this idea. However, I still pay more attention to the visitor's message because some plug-ins I have made require user feedback. So let me talk about it. As for implementation, let you do it yourself.

PS3: the force-attention function is also implemented using the same principle, and the code will not be published, which makes little sense.

PS4: I have posted emails to the official website and the group to inform the official website of this issue. I hope the blog Park can handle this issue as soon as possible.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.