Skip to content

Instantly share code, notes, and snippets.

@oniksfly
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oniksfly/dd12895b2cadd91971c3 to your computer and use it in GitHub Desktop.
Save oniksfly/dd12895b2cadd91971c3 to your computer and use it in GitHub Desktop.
SERP site position bookmarklet
function getUrlParameter(sParam){var sPageURL = window.location.search.substring(1);var sURLVariables = sPageURL.split('&');for (var i = 0; i < sURLVariables.length; i++) {var sParameterName = sURLVariables[i].split('=');if (sParameterName[0] == sParam) {return sParameterName[1];}}}
var site_url = '';
var message = '';
var $onPageItems = jQuery('#ires .g:not(#imagebox_bigimages)');
var start = getUrlParameter('start');
if (!start) {
start = 0;
} else {
start = parseInt(start);
}
var result = jQuery('#ires .g:not(#imagebox_bigimages) h3 a[href*=' + site_url + ']:eq(0)').parents('.g');
var current_page_position = $onPageItems.index(result) + 1;
var position = start + current_page_position;
if (current_page_position == 0) {
message = message + "There is no site on this page.\n";
} else {
message = message + "Position: " + position + ".\n";
}
alert(message);
@oniksfly
Copy link
Author

Use http://mrcoles.com/bookmarklet/ with 'include jQuery' option to create bookmarklet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment