From 44f401a207ef2ca39684367a4339a7b6ea7b9bb2 Mon Sep 17 00:00:00 2001 From: Charlie K Date: Mon, 12 Aug 2019 19:34:01 -0700 Subject: [PATCH] Hopefully fix all adsense issues --- js/dist/forum.js | 2 +- js/dist/forum.js.map | 2 +- js/package-lock.json | 13 +++++++---- js/src/forum/addAdsenseCompat.js | 37 +++++++++++++++++++------------- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/js/dist/forum.js b/js/dist/forum.js index b0a38fa..647429e 100644 --- a/js/dist/forum.js +++ b/js/dist/forum.js @@ -1,2 +1,2 @@ -module.exports=function(t){var e={};function o(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=14)}([function(t,e){t.exports=flarum.core.compat.app},function(t,e){t.exports=flarum.core.compat.extend},function(t,e,o){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}o.d(e,"a",function(){return n})},function(t,e){t.exports=flarum.core.compat["components/IndexPage"]},function(t,e){t.exports=flarum.core.compat["components/PostStream"]},function(t,e){t.exports=flarum.core.compat["components/HeaderPrimary"]},function(t,e){t.exports=flarum.core.compat["components/Page"]},function(t,e){t.exports=flarum.core.compat["components/EventPost"]},,,,,,,function(t,e,o){"use strict";o.r(e);var n=o(0),r=o.n(n),a=o(1),i=o(5),s=o.n(i),c=function(){Object(a.extend)(s.a.prototype,"config",function(t,e){if(!t&&!document.getElementsByClassName("Flagrow-Ads-under-header").length){var o=app.forum.attribute("flagrow.ads.under-header");if(o){var n=document.getElementsByClassName("App-content")[0],r=document.createElement("div");r.className="Flagrow-Ads-under-header",r.innerHTML=o,n.parentNode.insertBefore(r,n)}}})},d=o(3),u=o.n(d),p=function(){Object(a.extend)(u.a.prototype,"sidebarItems",function(t){var e=app.forum.attribute("flagrow.ads.under-nav-items");e&&!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&t.add("flagrow-ad",m.trust(e),-100)})},f=o(4),l=o.n(f),g=o(6),b=o.n(g),y=o(2),h=o(7),v=function(t){function e(){return t.apply(this,arguments)||this}Object(y.a)(e,t);var o=e.prototype;return o.icon=function(){return"fas fa-audio-description"},o.content=function(){return m("div",{className:"Flagrow-Ads-between-posts EventPost-info"},[m.trust(this.props.post.contentHtml())])},e}(o.n(h).a);r.a.initializers.add("flagrow-ads",function(t){t.postComponents.ad=v,c(),p(),Object(a.extend)(l.a.prototype,"view",function(t){var e=r.a.forum.attribute("flagrow.ads.between-posts");if(e&&t.children.length){var o=parseInt(r.a.forum.attribute("flagrow.ads.start-from-post")||1),n=parseInt(r.a.forum.attribute("flagrow.ads.between-n-posts")||5),a=t.children.filter(function(t){return"comment"===t.attrs["data-type"]});a.forEach(function(t,r){r>=o&&(r-o)%n==0&&r=o&&(r-o)%n==0&&r {\r\n\r\n if (isInitialized) { return; }\r\n\r\n if (document.getElementsByClassName('Flagrow-Ads-under-header').length) {\r\n return;\r\n }\r\n\r\n const advertisement = app.forum.attribute('flagrow.ads.under-header');\r\n\r\n if (advertisement) {\r\n\r\n var appElement = document.getElementsByClassName('App-content')[0];\r\n\r\n var adsElement = document.createElement('div');\r\n\r\n adsElement.className = 'Flagrow-Ads-under-header';\r\n adsElement.innerHTML = advertisement;\r\n\r\n appElement.parentNode.insertBefore(adsElement, appElement);\r\n }\r\n });\r\n}\r\n","import { extend } from 'flarum/extend';\r\nimport IndexPage from 'flarum/components/IndexPage';\r\n\r\nexport default function() {\r\n extend(IndexPage.prototype, 'sidebarItems', function(items) {\r\n\r\n\r\n const advertisement = app.forum.attribute('flagrow.ads.under-nav-items');\r\n\r\n if (advertisement && !(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))) {\r\n\r\n // set priority higher to move up\r\n items.add('flagrow-ad', m.trust(advertisement), -100);\r\n }\r\n });\r\n}\r\n","import EventPost from \"flarum/components/EventPost\";\r\n\r\nexport default class AdPostType extends EventPost {\r\n icon() {\r\n return 'fas fa-audio-description';\r\n }\r\n\r\n content() {\r\n return m('div', {\r\n className: 'Flagrow-Ads-between-posts EventPost-info'\r\n }, [\r\n m.trust(this.props.post.contentHtml())\r\n ]);\r\n }\r\n}\r\n","import app from 'flarum/app';\r\nimport addAdUnderHeader from './addAdUnderHeader';\r\nimport addAdUnderNavItems from './addAdUnderNavItems';\r\nimport addAdBetweenPosts from './addAdBetweenPosts';\r\nimport addAdsenseCompat from './addAdsenseCompat';\r\nimport AdPostType from './components/AdPostType';\r\n\r\napp.initializers.add('flagrow-ads', app => {\r\n app.postComponents.ad = AdPostType;\r\n\r\n addAdUnderHeader();\r\n addAdUnderNavItems();\r\n addAdBetweenPosts();\r\n addAdsenseCompat();\r\n});\r\n","import { extend } from 'flarum/extend';\r\nimport app from 'flarum/app';\r\nimport PostStream from 'flarum/components/PostStream';\r\n\r\nexport default function() {\r\n extend(PostStream.prototype, 'view', function(component) {\r\n const advertisement = app.forum.attribute('flagrow.ads.between-posts');\r\n\r\n if (advertisement && component.children.length) {\r\n const start = parseInt(app.forum.attribute('flagrow.ads.start-from-post') || 1);\r\n const between = parseInt(app.forum.attribute('flagrow.ads.between-n-posts') || 5);\r\n // We need to copy all comments first, otherwise there is no way to detect and jump the last comment\r\n const commentPosts = component.children.filter(post => post.attrs['data-type'] === 'comment');\r\n\r\n // Insert an inside every n comment\r\n commentPosts.forEach((post, i) => {\r\n if (i >= start && (i - start) % between === 0 && i < commentPosts.length - 1) {\r\n post.children.push(\r\n m('div.Flagrow-Ads-fake-poststream-item',\r\n m('article.Post.EventPost',\r\n m('div.Flagrow-Ads-between-posts.EventPost-info', m.trust(advertisement))\r\n )\r\n )\r\n );\r\n }\r\n });\r\n }\r\n });\r\n}\r\n","import { extend } from 'flarum/extend';\r\nimport app from 'flarum/app';\r\nimport Page from 'flarum/components/Page';\r\nimport PostStream from 'flarum/components/PostStream';\r\nimport IndexPage from 'flarum/components/IndexPage';\r\n\r\nexport default function() {\r\n extend(Page.prototype, 'config', function(component) {\r\n if ($(\".adsbygoogle\").length) {\r\n\r\n if (app.header_ad_active !== true) {\r\n (adsbygoogle = window.adsbygoogle || []).push({});\r\n app.header_ad_active = true;\r\n }\r\n\r\n if (!app.ads_index) {\r\n app.ads_index = app.history.stack.length\r\n } else if (app.ads_index !== app.history.stack.length) {\r\n app.ads_index = app.history.stack.length\r\n $(\".adsbygoogle\").each(function (i, e) {\r\n $(e).html($(e).html())\r\n });\r\n }\r\n }\r\n });\r\n\r\n extend(PostStream.prototype, 'config', function() {\r\n if ($(\".adsbygoogle\").length) {\r\n\r\n if (app.cache[this.discussion.id() + 'ads_active'] !== true && app.previous !== undefined && window.adsbygoogle.loaded !== true) {\r\n (adsbygoogle = window.adsbygoogle || []).push({});\r\n app.cache[this.discussion.id() + 'ads_active'] = true;\r\n }\r\n\r\n }\r\n });\r\n\r\n extend(IndexPage.prototype, 'config', function() {\r\n if ($(\".adsbygoogle\").length) {\r\n\r\n if (app.index_ad_active !== true && window.adsbygoogle.loaded !== true) {\r\n (adsbygoogle = window.adsbygoogle || []).push({});\r\n app.index_ad_active = true;\r\n }\r\n\r\n }\r\n });\r\n}\r\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://@flagrow/ads/webpack/bootstrap","webpack://@flagrow/ads/external \"flarum.core.compat['app']\"","webpack://@flagrow/ads/external \"flarum.core.compat['extend']\"","webpack://@flagrow/ads/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@flagrow/ads/external \"flarum.core.compat['components/IndexPage']\"","webpack://@flagrow/ads/external \"flarum.core.compat['components/PostStream']\"","webpack://@flagrow/ads/external \"flarum.core.compat['components/HeaderPrimary']\"","webpack://@flagrow/ads/external \"flarum.core.compat['components/Page']\"","webpack://@flagrow/ads/external \"flarum.core.compat['components/EventPost']\"","webpack://@flagrow/ads/./src/forum/addAdUnderHeader.js","webpack://@flagrow/ads/./src/forum/addAdUnderNavItems.js","webpack://@flagrow/ads/./src/forum/components/AdPostType.js","webpack://@flagrow/ads/./src/forum/index.js","webpack://@flagrow/ads/./src/forum/addAdBetweenPosts.js","webpack://@flagrow/ads/./src/forum/addAdsenseCompat.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","flarum","core","compat","_inheritsLoose","subClass","superClass","constructor","__proto__","__webpack_exports__","addAdUnderHeader","extend","HeaderPrimary","isInitialized","context","document","getElementsByClassName","length","advertisement","app","forum","attribute","appElement","adsElement","createElement","className","innerHTML","parentNode","insertBefore","addAdUnderNavItems","IndexPage","items","test","navigator","userAgent","add","trust","AdPostType","icon","content","this","props","post","contentHtml","EventPost","initializers","postComponents","ad","PostStream","component","children","start","parseInt","between","commentPosts","filter","attrs","forEach","push","Page","$","window","adsbygoogle","header_ad_active","_unused","ads_index","history","stack","each","e","html","_unused2","index_ad_active","loaded","_unused3"],"mappings":"2BACA,IAAAA,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF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BAAgB3C,QAAU4C,OAAOC,cAEP,IAAxB3C,IAAIqD,kBAA0D,IAA9BX,OAAOC,YAAYW,OAAiB,CACpE,KACKX,YAAcD,OAAOC,aAAe,IAAIJ,KAAK,IAChD,MAAAgB,GACE,OAEJvD,IAAIqD,iBAAkB","file":"forum.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 14);\n","module.exports = flarum.core.compat['app'];","module.exports = flarum.core.compat['extend'];","export default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}","module.exports = flarum.core.compat['components/IndexPage'];","module.exports = flarum.core.compat['components/PostStream'];","module.exports = flarum.core.compat['components/HeaderPrimary'];","module.exports = flarum.core.compat['components/Page'];","module.exports = flarum.core.compat['components/EventPost'];","import { extend } from 'flarum/extend';\r\nimport HeaderPrimary from 'flarum/components/HeaderPrimary';\r\n\r\nexport default function () {\r\n extend(HeaderPrimary.prototype, 'config', (isInitialized, context) => {\r\n\r\n if (isInitialized) { return; }\r\n\r\n if (document.getElementsByClassName('Flagrow-Ads-under-header').length) {\r\n return;\r\n }\r\n\r\n const advertisement = app.forum.attribute('flagrow.ads.under-header');\r\n\r\n if (advertisement) {\r\n\r\n var appElement = document.getElementsByClassName('App-content')[0];\r\n\r\n var adsElement = document.createElement('div');\r\n\r\n adsElement.className = 'Flagrow-Ads-under-header';\r\n adsElement.innerHTML = advertisement;\r\n\r\n appElement.parentNode.insertBefore(adsElement, appElement);\r\n }\r\n });\r\n}\r\n","import { extend } from 'flarum/extend';\r\nimport IndexPage from 'flarum/components/IndexPage';\r\n\r\nexport default function() {\r\n extend(IndexPage.prototype, 'sidebarItems', function(items) {\r\n\r\n\r\n const advertisement = app.forum.attribute('flagrow.ads.under-nav-items');\r\n\r\n if (advertisement && !(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))) {\r\n\r\n // set priority higher to move up\r\n items.add('flagrow-ad', m.trust(advertisement), -100);\r\n }\r\n });\r\n}\r\n","import EventPost from \"flarum/components/EventPost\";\r\n\r\nexport default class AdPostType extends EventPost {\r\n icon() {\r\n return 'fas fa-audio-description';\r\n }\r\n\r\n content() {\r\n return m('div', {\r\n className: 'Flagrow-Ads-between-posts EventPost-info'\r\n }, [\r\n m.trust(this.props.post.contentHtml())\r\n ]);\r\n }\r\n}\r\n","import app from 'flarum/app';\r\nimport addAdUnderHeader from './addAdUnderHeader';\r\nimport addAdUnderNavItems from './addAdUnderNavItems';\r\nimport addAdBetweenPosts from './addAdBetweenPosts';\r\nimport addAdsenseCompat from './addAdsenseCompat';\r\nimport AdPostType from './components/AdPostType';\r\n\r\napp.initializers.add('flagrow-ads', app => {\r\n app.postComponents.ad = AdPostType;\r\n\r\n addAdUnderHeader();\r\n addAdUnderNavItems();\r\n addAdBetweenPosts();\r\n addAdsenseCompat();\r\n});\r\n","import { extend } from 'flarum/extend';\r\nimport app from 'flarum/app';\r\nimport PostStream from 'flarum/components/PostStream';\r\n\r\nexport default function() {\r\n extend(PostStream.prototype, 'view', function(component) {\r\n const advertisement = app.forum.attribute('flagrow.ads.between-posts');\r\n\r\n if (advertisement && component.children.length) {\r\n const start = parseInt(app.forum.attribute('flagrow.ads.start-from-post') || 1);\r\n const between = parseInt(app.forum.attribute('flagrow.ads.between-n-posts') || 5);\r\n // We need to copy all comments first, otherwise there is no way to detect and jump the last comment\r\n const commentPosts = component.children.filter(post => post.attrs['data-type'] === 'comment');\r\n\r\n // Insert an inside every n comment\r\n commentPosts.forEach((post, i) => {\r\n if (i >= start && (i - start) % between === 0 && i < commentPosts.length - 1) {\r\n post.children.push(\r\n m('div.Flagrow-Ads-fake-poststream-item',\r\n m('article.Post.EventPost',\r\n m('div.Flagrow-Ads-between-posts.EventPost-info', m.trust(advertisement))\r\n )\r\n )\r\n );\r\n }\r\n });\r\n }\r\n });\r\n}\r\n","import {extend} from 'flarum/extend';\r\nimport app from 'flarum/app';\r\nimport Page from 'flarum/components/Page';\r\nimport PostStream from 'flarum/components/PostStream';\r\nimport IndexPage from 'flarum/components/IndexPage';\r\n\r\nexport default function () {\r\n extend(Page.prototype, 'config', function () {\r\n if ($(\".adsbygoogle\").length && window.adsbygoogle) {\r\n\r\n if (app.header_ad_active !== true) {\r\n try {\r\n (adsbygoogle = window.adsbygoogle || []).push({});\r\n } catch {\r\n return;\r\n }\r\n app.header_ad_active = true;\r\n }\r\n\r\n if (!app.ads_index) {\r\n app.ads_index = app.history.stack.length\r\n } else if (app.ads_index !== app.history.stack.length) {\r\n app.ads_index = app.history.stack.length;\r\n $(\".adsbygoogle\").each(function (i, e) {\r\n $(e).html($(e).html())\r\n });\r\n }\r\n }\r\n });\r\n\r\n extend(PostStream.prototype, 'config', function () {\r\n if ($(\".adsbygoogle\").length && window.adsbygoogle) {\r\n try {\r\n (adsbygoogle = window.adsbygoogle || []).push({});\r\n } catch {\r\n return;\r\n }\r\n }\r\n });\r\n\r\n extend(IndexPage.prototype, 'config', function () {\r\n if ($(\".adsbygoogle\").length && window.adsbygoogle) {\r\n\r\n if (app.index_ad_active !== true && window.adsbygoogle.loaded !== true) {\r\n try {\r\n (adsbygoogle = window.adsbygoogle || []).push({});\r\n } catch {\r\n return;\r\n }\r\n app.index_ad_active = true;\r\n }\r\n\r\n }\r\n });\r\n}\r\n"],"sourceRoot":""} \ No newline at end of file diff --git a/js/package-lock.json b/js/package-lock.json index cd44447..063fe50 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -2137,7 +2137,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -2502,7 +2503,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2550,6 +2552,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2588,11 +2591,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.0.3", - "bundled": true + "bundled": true, + "optional": true } } }, diff --git a/js/src/forum/addAdsenseCompat.js b/js/src/forum/addAdsenseCompat.js index a693b59..d642804 100644 --- a/js/src/forum/addAdsenseCompat.js +++ b/js/src/forum/addAdsenseCompat.js @@ -1,22 +1,26 @@ -import { extend } from 'flarum/extend'; +import {extend} from 'flarum/extend'; import app from 'flarum/app'; import Page from 'flarum/components/Page'; import PostStream from 'flarum/components/PostStream'; import IndexPage from 'flarum/components/IndexPage'; -export default function() { - extend(Page.prototype, 'config', function(component) { - if ($(".adsbygoogle").length) { +export default function () { + extend(Page.prototype, 'config', function () { + if ($(".adsbygoogle").length && window.adsbygoogle) { if (app.header_ad_active !== true) { - (adsbygoogle = window.adsbygoogle || []).push({}); + try { + (adsbygoogle = window.adsbygoogle || []).push({}); + } catch { + return; + } app.header_ad_active = true; } if (!app.ads_index) { app.ads_index = app.history.stack.length } else if (app.ads_index !== app.history.stack.length) { - app.ads_index = app.history.stack.length + app.ads_index = app.history.stack.length; $(".adsbygoogle").each(function (i, e) { $(e).html($(e).html()) }); @@ -24,22 +28,25 @@ export default function() { } }); - extend(PostStream.prototype, 'config', function() { - if ($(".adsbygoogle").length) { - - if (app.cache[this.discussion.id() + 'ads_active'] !== true && app.previous !== undefined && window.adsbygoogle.loaded !== true) { + extend(PostStream.prototype, 'config', function () { + if ($(".adsbygoogle").length && window.adsbygoogle) { + try { (adsbygoogle = window.adsbygoogle || []).push({}); - app.cache[this.discussion.id() + 'ads_active'] = true; + } catch { + return; } - } }); - extend(IndexPage.prototype, 'config', function() { - if ($(".adsbygoogle").length) { + extend(IndexPage.prototype, 'config', function () { + if ($(".adsbygoogle").length && window.adsbygoogle) { if (app.index_ad_active !== true && window.adsbygoogle.loaded !== true) { - (adsbygoogle = window.adsbygoogle || []).push({}); + try { + (adsbygoogle = window.adsbygoogle || []).push({}); + } catch { + return; + } app.index_ad_active = true; }