javascript - Is it possible to count how many times this bookmarklet is clicked and if so, how to get the number of clicks in to a file? -
i have javascript code uses iframes
pull data required. made in bookmarklet. wanted know if possible count how many times bookmarklet clicked , if so, how number of clicks in file? original code:
javascript:(function () { if (!$('#omniboxdiv').length) { var strload = '<div id="omniboxdiv" style="display: block;background-color: gold;font-size: 1.25em;z-index: 1000;position: fixed;width: 96%;padding: 2%; text-align: center">loading...</div>'; var divload = $(strload).prependto('body'); } if(typeof omnibox === 'object'){ omnibox.msg(); return; } omnibox = this; var fstatus = $('tr:has(td:contains("fstatus")):eq(1)>td:eq(1)').text(); var mstatus = $('tr:has(td:contains("mstatus")):eq(2)>td:eq(1)').text(); var flink = $('a:contains("f profile")').attr('href'); this.msg = function(){ '<tr><td></td><td>fstatus:</td><td>'+fstatus+'</td></tr>'+ '<tr><td>igc</td><td></td><td></td></tr>' str = '<table>' + str + '</table><a href="javascript:omnibox.closeomnibox();" style="background-color: darkorange;display: inline-block;padding: 0.5% 1%;cursor: pointer;">close</a>'; $('#omniboxdiv').html(str); } }; this.closeomnibox = function(){ $('#omniboxdiv').remove(); }; var fcheck = false, mcheck = false; var iff = $('<iframe>'), ifm = $('<iframe>'); $('body').append(iff);$('body').append(ifm);$('body'); iff.attr('id','iff').css('display','none').attr('src',flink).on('load',function(){ "code" }, function(){ fcheck = true; msg(); }); }); "code" }, function(){ mcheck = true; msg(); }); }); }); function whilst (condition, action, final) { var handle = setinterval(function () { if (condition()) { action(); } else { clearinterval(handle); final(); } }, 500); } })();
you can use global variable in bookmarklet.
if(typeof count === number){ count++; } else { count=0; }
you can choose more specific name variable avoid conflicts on current page. can use localstorage
save count if want
Comments
Post a Comment