if( location.href.indexOf('etsy.com/view_listing') == -1 ) { // not on a listing page - stop working return } a=document.getElementsByTagName('a'); var ys,ts; // loop through the links on the page looking for shop links for( l = 0; l < a.length; l++ ) { k = a[l]; if( k.href ) { m = /shop.php\?user_id=(\d+)/.exec(k.href); if( m ) { if ( k.title == 'Your Shop' ) { // capture my shop ID ys = m[1] } else if ( k.firstChild && k.firstChild.data && k.firstChild.data == 'shop' ) { // capture the current shop's ID ts = m[1]; break } } } } if( ys == ts ){ // this is in my shop - I should go to the edit page m = location.search.match(/listing_id=(\d+)/); location = 'http://www.etsy.com/reactivate_listing.php?listing_id=' + m[1]; }