[Grimace original] Google expansion-zhihu V2.0 and grimace Google-v2.0

Source: Internet
Author: User

[Grimace original] Google expansion-zhihu V2.0 and grimace Google-v2.0

Purpose:

Use the keyboard to replace the mouse and make a quiet girl!

Function:

Function Buttons Description
Go to the search box. Q  
Open Homepage W  
Open topic E  
Open discovery R  
Open message M  
Open personal homepage U  
Open my draft C  
Open my favorites S  
Open the following questions G  
Open the question that I was invited to answer Y  
Open the first question in the current visible range Enter Only for <Latest News>
Auto load more Space or space Only when the page loading mode is scroll Loading
Previous or next Else or → Page loading only
When you forget these shortcut keys, you can directly press the h key to bring up help information.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Implementation Code

Only two key points are described:

1) Automatic LoadingMore

Description: When refreshing the latest updates, the bottom will appear during the rolling process.'More'Button. You need to click it each time.

Ideas: The Click Event of the 'more' button is automatically triggered each time it is rolled to the bottom.

Implementation Code:

If (e. keyCode = 40 | e. keyCode = 32) {// down arrow | space var scrollTop = $ (window ). scrollTop (); var scrollHeight = $ (document ). height (); var returns wheight = $ (window ). height (); if (scrollTop + windowHeight = scrollHeight) {document. getElementById ('zh-load-more '). click ();}}

2) open the first problem in the current visible range

Description: When refreshing the latest news, you can see the question you are interested in. You need to click it manually each time. Can you press enter directly to open this question with one click? The answer is yes.

Ideas: By analyzing the html source code, we know that every problem is a div with a fixed height. Therefore, you can obtain the target by dividing the Y coordinate of the current scroll bar by the div height.

Implementation Code:

If (e. keyCode = 13) {// press Enter: directly open the question closest to the top. // The height of each question = 219 var y = GetPageScroll (). y; // The Position of the scroll bar. var index = parseInt (y)/220 ); // current div var title = $ ('# js-home-feed-list div.feed-item'hangzhou.eq(index).find('h2'hangzhou.html (); var a_href = $ (' # js-home-feed-list div. feed-item '). eq (index ). find ('h2 '). find ('A '). attr ('href '); window. open ('https: // www.zhihu.com '+ a_href );
} Function GetPageScroll () {var x, y;
If (window. pageYOffset ){
// All records t IE y = window. pageYOffset; x = window. pageXOffset ;}
Else if(document.doc umentElement & document.doc umentElement. scrollTop ){
// IE 6 Strict y = document.doc umentElement. scrollTop; x = document.doc umentElement. scrollLeft ;}
Else if (document. body ){
// All other IE y = document. body. scrollTop; x = document. body. scrollLeft;} return {X: x, Y: y };}

 

Complete code: = click I =

 

 

V1.0:The previous page and next page functions are simply implemented. Click me for details!

 

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.