So I’ve been investigating this a lot and I think I found the cause of the problem.
For me, at least, the problem only occurs when clicking the a thumbnail on a generic /read page and does not occur when a specific page is loaded directly. (Clicking on the first thumbnail on
https://www.fakku.net/doujinshi/dl-action-91-english/read causes the counter to remain at 5. Loading
https://www.fakku.net/doujinshi/dl-action-91-english/read#page=1 directly and the counter works normally.)
It’s not a very complicated problem, so I’ll just explain it in step form.
*The
if block I mention below is the one located on lines 207 to 217. Copied below:
if (params.page != 'thumbs' && $('#advertisement-page').length) {
adSkipCounter = 5;
var interval = setInterval(function() {
$('#closePageAd').html('Skip Ad in ' + adSkipCounter + '...');
adSkipCounter--;
if (adSkipCounter == 0) {
$('#closePageAd').html('Skip Ad ← ');
clearInterval(interval);
}
}, 1000);
}
1. Load
https://www.fakku.net/doujinshi/dl-action-91-english/read
2. $(document).ready(); invoked
3. update_pages(); invoked.
4. if block invoked. The page is initially loaded as the
"thumbnail page", the condition is not satisfied so the counter does not start.
5. Click on first thumbnail. Hyperlink links to
href="#page=1”
6. $(window).on('hashchange', function()); invoked since the hash in the URL is changed.
7. update_pages(); invoked.
// Note that since this is just a simple hashchange, the page is not reloaded. So $(document).ready(); is not invoked again.
8. Image page is loaded.
9. update_ads(); invoked.
10. Ads now shown.
11. Even though the page is now considered a
"not thumbnail page", it was initially loaded the
"thumbnail page". The
if block mentioned in Step 4 is never checked again since it is directly under
$(document).ready(); so there is no possible way for the countdown to start without the page reloading.
Because linking directly to the page loads the page initially as
"not thumbnail page", the
if block's condition is satisfied when
$(document).ready(); is run.
This is an extremely short JSFiddle that sort of simulates this problem
https://jsfiddle.net/eo8fj5x5/.
The obvious solution would be to wrap the
if block in a function and call it in
update_pages();. Additional variables can be included to prevent the ad from showing up on every page.