javascript - How to use JS Regex for getting value of query from a google query link? (Chrome Extension) -


i have data has links browser history. want find out links of google queries , more specifically, in queries contain keyword meaning.

have tried far.

function extractdatafromhistory(){     //document.getelementbyid('history').innerhtml = "hi";     chrome.history.search({text: "", maxresults: 1000}, function(historyitems){         var data = '';         for(var i=0; i<historyitems.length; i++){             var url = historyitems[i].url;             if(url.indexof('google')>-1 && url.search('q=')){                 //data += historyitems[i].url.indexof('google');                 data += url;             }         }         document.getelementbyid('history').innerhtml = data;     }); } 

the sample data get:

https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0cbsqfjaa&url=http%3a%2f%2fwww.w3schools.com%2fjsref%2fjsref_match.asp&ei=p-mtu7fgkzczuaso6okqaw&usg=afqjcnhsd5zsdxhlmusud1lde1ksdvdpuw&sig2=woxgzgk_pqssrijyyxijrq&bvm=bv.69837884,d.c2e

https://www.google.co.in/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=utf-8#q=js%20regex%20match

https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0cb0qfjaa&url=http%3a%2f%2fwww.w3schools.com%2fjsref%2fjsref_split.asp&ei=doitu9fygiswuatqwiladg&usg=afqjcngzld-miahz1yk3hwzuwpitkgndrw&sig2=2odeywr7vsjzjum-gkbjjg&bvm=bv.69837884,d.c2e

https://www.google.co.in/search?q=js+string+operations&oq=js+string+operations&aqs=chrome..69i57j0l5.3671j0j4&sourceid=chrome&es_sm=122&ie=utf-8

try regex:

'google.+q=(.+?)&' 

the part in parenthesis search query.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -