[rellect] AdBlock Detector [Deleted]

We needed to have different messages for unregistered visitors and members of our site. Members get a link to Account Upgrade and non-members don't.

We added a new phrase to be shown to unregistered visitors and named it "rellect_adblock_detector_message_public".

Then we changed the "rellect_adblock_detector_js" template to
Code:
<xen:require css="rellect_adblock_detector.css" />

<xen:comment>
# <script> tags already opened in the 'page_container_js_body' hook.
</xen:comment>

XenForo.rellect = XenForo.rellect || {};

XenForo.rellect.AdBlockDetectorParams = {
    expiry: {$expiry},
    hours: {$hours},
    canDismiss: {$canDismissAlert},
    type: "{$xenOptions.rellect_adblock_detector_alert_type}",
    phrases: {
        title: "{xen:jsescape {xen:phrase rellect_adblock_detector_title}}",
        message: "{xen:jsescape {xen:if "{$visitor.user_id}", "{xen:phrase rellect_adblock_detector_message}", "{xen:phrase rellect_adblock_detector_message_public}"}}",
        close: "{xen:jsescape {xen:phrase close}}"
    },
    loadScript: function(url, loadFn, errorFn){
        var script = $('<script />', {
            async: 'async',
            src: url
        })
        .load(function(){
            if(loadFn){
                loadFn();
                loadFn = null;
            }
        })
        .error(function(jqXHR, textStatus){
            /* When script is blocked, textStatus is undefined. */
            if(typeof textStatus !== 'undefined'){
                return;
            }

            if(errorFn){
                errorFn(jqXHR, textStatus);
                errorFn = null;
            }
        });

        document.getElementsByTagName('body')[0].appendChild(script[0]);
    }
};

var AdBlockDetectorWorkaround = function(){
    /* This is just in case the handler script is blocked by the adblocker */
    if(!XenForo.rellect.AdBlockDetector){
        console.log('AdBlock detector failed. Trying workaround.');
        XenForo.ajax('index.php', {dataType: 'html', AdblockDetector: 1}, function(ajaxData){
            if(XenForo.hasTemplateHtml(ajaxData)){
                try{
                    jQuery.globalEval(ajaxData.templateHtml);
                }
                catch(e){}
            }
        }, {
            error: function(){
                console.log('AdBlock detector workaround failed.');
            }
        });
    }
};

XenForo.rellect.AdBlockDetectorParams.loadScript(
    'js/rellect/AdBlockDetector/handler{xen:if "{$xenOptions.uncompressedJs} == '0'", ".min"}.js?rev={$xenAddOns.rellect_adblock_detector}',
    false,
    AdBlockDetectorWorkaround
);

Works like expected. ;)
 
  • Like
Reactions: rdn
Hey, some user includes me have the probem with firefox, that the user has deativated the adblocker but once in a while they get the message again. Its realy bad if you surf on the website and than the blocker shows up....
 
Hey, some user includes me have the probem with firefox, that the user has deativated the adblocker but once in a while they get the message again. Its realy bad if you surf on the website and than the blocker shows up....
There is a beta version available, please try to update and let me know if it still happens.
Use the same download link from the last mail from me.
 
@rellect - How can I remove the exclamation point from the notice?

Nevermind - I found it.

In case anyone looking for it: Style Properties: [rellect] AdBlock Detector -> alert icon
 
Last edited:
I'm using the latest beta and a member just posted the following:

Hey Amin, I use ghostery and adblock plus, in firefox, but I white list your site(s) in both of them.

Yet I still get a message on most pages saying "please white list us". What's up?
 
Address of my site is http://www.mu-43.com

I will ask if he sees ads, but it may be hard to determine because the only ads shown to logged in members are Amazon ads in the footer with a low fill rate.
He may check as a guest if there are more ads for guests.
I just checked in firefox with ADP and Ghostery, whitelisted the site in both, and I don't get the notice.
 
Thanks, in the meanwhile I'll add anyone who says that they whitelisted us to a usergroup that lets them bypass the notice.
 
Would it be possible to have a different kind of notifications for different usergroups?

For guests I like to have a sticky notification while for registered users a simple Textbox on top of a page would be enough.
 
Would it be possible to have a different kind of notifications for different usergroups?

For guests I like to have a sticky notification while for registered users a simple Textbox on top of a page would be enough.
Hey,
This was suggested before, and I plan to add this functionality in a future update.
 
Great, thanks!

BTW, I have a "bug" with this AddOn enabled.

Not all but some registered users have a slow text typing in quick reply on thread pages if this addon is enabled.

I disabled the addon now and they don't have this problem anymore.

I don't know what to do know. I guess I will bypass it for registered users and leave it for guests only, but thats not what I want :-(
 
rellect updated [rellect] AdBlock Detector with a new update entry:

v1.7.2

  • Fixed a case where Ghostery couldn't be detected.
  • Fixed a case where the notice alert won't show if there are no breadcrumbs in the page (only applies to custom themes which may have deleted this).
  • Added few changes to avoid the recent reports about firefox users who whitelisted the domain still got the alert. If this still happens after this update, please let me know.
    ...

Read the rest of this update entry...
 
Could you add the option to change the notice text in the ACP options page? Would make it easier.
That's a little problematic since some sites have multiple languages, so if this will be a setting, they won't be able to translate it.
 
That's a little problematic since some sites have multiple languages, so if this will be a setting, they won't be able to translate it.

I understand :) But where can I change the user notice? I just want to slightly change the text.
 
Back
Top Bottom