if (window.location.pathname + window.location.search == '/my.policy' ) { for (i = 1; i <=10; i++ ) { var result = 0; result = clicker(); if ( result == 1 ) { break; } } } function clicker () { setTimeout(function () { var btnav = document.getElementsByClassName("cphDownloadBtnDiv"); if (btnav.length != 0) { btnav[0].click(); return 1; } }, 1000) }