| Available JS Variables | |
|---|---|
| allKeywords | Unique array of all found keywords on page, this will not have duplicates |
| searchTerm | Term searched for by user |
| regionCode | Google format region/country code |
| languageCode | Lanuage that is being searched |
There is a plug element after each result provided for you to place your output.
if (typeof allKeywords == 'undefined') {
console.log('NOT plugable page');
} else {
console.log('IS plugable page');
}
console.log(searchTerm); // String: search term
console.log(allKeywords); // Array: unique list of all results
console.log(regionCode); // String: region code
console.log(languageCode); // String: language code
// Output all keywords on page
$('plug').each(function( index ) {
console.log(this.keyword);
});
// Create an element for each search result
$('plug').each(function( index ) {
// Use a child div so it doesn't influence anyone else's extensions/plugins and theirs don't influence ours
var a = document.createElement("a");
a.innerHTML = (this.keyword.length * 100).toLocaleString();
a.setAttribute('class', 'HappyPluginProvider');
a.setAttribute('href', 'https://google.com/search?q=' + encodeURIComponent(this.keyword + ' and mangoes'));
a.setAttribute('target', '_blank');
this.appendChild(a);
// console.log(this.keyword);
});
// Add a button to the pluginButton area
var a = document.createElement("a");
a.innerHTML = "Run Our Thingy";
a.setAttribute('class', 'roundButton');
a.setAttribute('onclick', 'javascript:alert("boo!"); void 0;');
$('pluginButtons')[0].appendChild(a);
// Add some text output up in the header area
$('pluginWhatever').append('<div class="leftAlign" style="max-width: 500px; background: #f9f9f9; color: #111; padding: 3px; border-radius: 5px;">Spider Plugin processed:<br>'+allKeywords.length.toLocaleString()+' keywords</div>');