Last active
July 12, 2020 07:47
-
-
Save neodigm/26ea719ba2e2de4c10e94e89c67214cb to your computer and use it in GitHub Desktop.
Persist Long Tail Keywords from the Google Drop-down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Persist Long Tail Key Words from Google SERP | |
var fLong = (function(){ | |
var _aPKW = localStorage.getItem( "gogl_ai_keywords" ); | |
if( _aPKW ){ | |
_aPKW = JSON.parse( _aPKW ); | |
}else{ | |
_aPKW = []; | |
} | |
return { | |
doit : function(){ | |
[].slice.call( document.querySelectorAll("[role='listbox'] LI>DIV>DIV>SPAN") ).filter( function( _e ){ | |
_aPKW.push( _e.textContent ); | |
}); | |
_aPKW = _aPKW.filter((v, i, a) => a.indexOf(v) === i); // dedupe | |
localStorage.setItem("gogl_ai_keywords", JSON.stringify( _aPKW ) ); | |
}, | |
report : function(){ | |
console.table( _aPKW ); | |
}, | |
clear : function(){ | |
_aPKW = []; | |
localStorage.setItem("gogl_ai_keywords", JSON.stringify( _aPKW ) ); | |
} | |
} | |
})(); | |
setInterval( function(){ | |
fLong.doit(); | |
}, 200); | |
var oMO = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
//fLong.doit(); | |
}); | |
}); | |
var observerConfig = { | |
attributes: true, | |
childList: true, | |
characterData: true | |
}; | |
oMO.observe( document.querySelectorAll("[role='listbox']")[0], observerConfig); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This JavaScript captures and stores all the phrases that Google auto-populates into the drop-down as you type for the purpose of creating long tail keywords.
Paste into a snippet, navigate to the google search, run the snippet, type the origins of you keywords. When done you will find a list of all the long tail keywords in the local storage item named "gogl_ai_keywords". In the console fire fLong.report(); to view results. Cut and paste into Textpad and fire macro named "gogl long tail console table", sort and dedupe.