A simple way to condition your JS code execution based on page types for Blogger blogs.
Add to your XML template the next script tag.
<script src="https://cdn.jsdelivr.net/gh/1e90ff/dorothy@1.0.1/dorothy.min.js" />
dorothy(pageTypes, callbackFn[, applyMobile=true]);
pageTypes
, a single or multiple page-types (pipe-delimited).callbackFn
, a function with the routine to execute.applyMobile
, a flag to enable or disable running on mobile requests.
// Available page types:
// ALL, ITEM, POST, PAGE, FEED, HOME,
// QUERY, LABEL, ERROR, SEARCH, ARCHIVE
dorothy('HOME', function (data) {
alert('Welcome to ' + data.blog.title + '!');
});
dorothy('POST|PAGE', function (data) {
alert('You are reading: "' + data.view.title + '".');
}, false);
See the LICENSE file included in this project for details.