Skip to content
Extraits de code Groupes Projets
Valider bd2f0b20 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

simple detection whether ad blocker is enabled

parent ecdf19cd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -226,13 +226,16 @@ class View implements ViewInterface
$this->latest_version_available = UpdateCheck::isNewestVersionAvailable();
$this->disableLink = Common::getRequestVar('disableLink', 0, 'int');
$this->isWidget = Common::getRequestVar('widget', 0, 'int');
$developmentModeEnabled = Development::isEnabled();
if (Development::isEnabled()) {
if ($developmentModeEnabled) {
$cacheBuster = rand(0, 10000);
} else {
$cacheBuster = UIAssetCacheBuster::getInstance()->piwikVersionBasedCacheBuster();
}
$this->isDevelopmentModeEnabled = $developmentModeEnabled;
$this->cacheBuster = $cacheBuster;
$this->loginModule = Piwik::getLoginPluginName();
......
......@@ -4,6 +4,10 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
// see https://github.com/piwik/piwik/issues/5094 used to detect an ad blocker
var hasBlockedContent = false;
(function () {
angular.module('piwikApp.service').factory('piwikApi', piwikApiService);
......
......@@ -50,6 +50,7 @@
"UndoPivotBySubtable": "This report has been pivoted %s Undo pivot",
"PivotBySubtable": "This report is not pivoted %s Pivot by %s",
"QuickAccessTitle": "Search for menu entries, segments and websites. Shortcut: Press 'f' to search.",
"Segments": "Segments"
"Segments": "Segments",
"AdblockIsMaybeUsed": "In case you are using an ad blocker, please disable it for this site to make sure Piwik works without any issues."
}
}
<script type="text/javascript">
if ('undefined' === (typeof hasBlockedContent) || hasBlockedContent !== false) {
(function () {
{# most likely jQuery is not available, have to use vanilla JS here #}
{% if not isDevelopmentModeEnabled %}
{# if development mode is disabled it is most likely blocked because having piwik in pathname #}
{# if development mode is enabled it might be as well blocked because of not loaded piwik-api.js #}
if (location && location.pathname && -1 === location.pathname.indexOf('piwik')) {
// it is most likely not an issue related to ad blocker, maybe failed to load from server
return;
}
{% endif %}
var body = document.getElementsByTagName('body');
if (!body || !body[0]) {
return;
}
var warning = document.createElement('h3');
warning.innerHTML = '{{ 'CoreHome_AdblockIsMaybeUsed'|translate|e('js') }}';
body[0].appendChild(warning);
warning.style.color = 'red';
warning.style.fontWeight = 'bold';
warning.style.marginLeft = '16px';
warning.style.marginBottom = '16px';
})();
}
</script>
\ No newline at end of file
......@@ -22,7 +22,6 @@
{% include "@CoreHome/_favicon.twig" %}
{% include "_jsGlobalVariables.twig" %}
{% include "_piwikTag.twig" %}
{% include "_jsCssIncludes.twig" %}
<!--[if IE]>
......@@ -49,5 +48,6 @@
{% endblock %}
{% include "@CoreHome/_adblockDetect.twig" %}
</body>
</html>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter