Paypal With Hotspot And Walled Garden Bypass - MikroTik Script RouterOS

These scripts maintain a current list of PayPal ips in the walled garden.

These scripts are necessary to compensate for a deficiency in Mikrotik's hotspot walled-garden routine. The walled garden uses "/ip dns cache" to allow ips through the walled garden for SSL connections. Unfortunately, www.paypal.com ips (the actual webpage) stay in the cache for less than 5 minutes, and www.paypalobjects.com (the cascaded style sheet) ips stay there less than 20 seconds. Once Mikrotik corrects the challenge, these scripts will no longer be necessary, but until then...
These two domains should be entered in "/ip hotspot walled-garden":

www.paypal.com
www.paypalobjects.com

This script is paypal. It should be scheduled to run every 15 seconds. Use a start-time that will schedule this script to run 5 seconds before or after the ppupdate script below, so they don't run at the same time. I use 00:00:05 as the start-time.

:local ppobjip [:resolve www.paypalobjects.com];
:local today [/system clock get date];
:local paypalobject [/ip hotspot walled-garden ip find dst-address=$ppobjip];
:local thisdate none;
:local noip true;

:foreach i in=$paypalobject do={
    :set noip false;
    :set thisdate [/ip hotspot walled-garden ip get $i comment];
    :if ($thisdate != ("ppobj $today")) do={
            /ip hotspot walled-garden ip set $i comment="ppobj $today";
    }
}

:if ($noip) do={
    :log info "paypal script adding $ppobjip";
    /ip hotspot walled-garden ip add dst-address=$ppobjip comment="ppobj $today";
}
This script is ppupdate. It should be run manually once before use, and then scheduled to run once a day at 23:30:00.

:local today [/system clock get date];
:local old [/ip hotspot walled-garden ip find comment~"ppobj*"];
:local thisrem none;
:local thisip none;

:foreach i in=$old do={
    :set thisrem [/ip hotspot walled-garden ip get $i comment];

    :if ($thisrem != ("ppobj $today")) do={
        /ip hotspot walled-garden ip remove $i;
    }
}

:resolve www.paypal.com;

:global paypalips [/ip dns cache find name="www.paypal.com"];
:global oldips [/ip hotspot walled-garden ip find comment="paypal"];

:foreach x in=$oldips do={
    /ip hotspot walled-garden ip remove $x;
}

:foreach i in=$paypalips do={
    :set thisip [/ip dns cache get $i address];
    /ip hotspot walled-garden ip add comment="paypal" dst-address=$thisip;
}
Credit: wiki.mikrotik.com