Simplify this document.referrer check
Easily! You can use a regular expression to match page[1-7].html and also search/?:

if ($('.content').length &amp;&amp; document.referrer.match(/page[1-7]\.html|search\/\?/)) {
        window.location.href = document.referrer;
};


And never write conditions in such wasteful way:


if (A &amp;&amp; B || A &amp;&amp; C || A &amp;&amp; D) {



when it can be easily simplified to:

if (A &amp;&amp; (B || C || D)) {