Last active
June 8, 2019 01:31
-
-
Save julien51/f4a3e9d63bcd5b4756b36e7ac0fb2fe5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Loading the script | |
<script> | |
(function (d, s) { | |
var js = d.createElement(s), | |
sc = d.getElementsByTagName(s)[0]; | |
js.src = "https://paywall.unlock-protocol.com/static/unlock.1.0.min.js"; | |
sc.parentNode.insertBefore(js, sc); | |
}(document, "script")); | |
</script> | |
// Configuring the snippet | |
<script> | |
var unlockProtocolConfig = { | |
locks: { | |
'0x2BDb87333b15E20d948BC5235569f0cA3E6c707C': { | |
name: 'One Day', | |
}, | |
'0x1b75BC108a0259355475CE45CdFB5599361abcbe': { | |
name: 'A Good Deal!', | |
}, | |
}, | |
icon: | |
'http://lofrev.net/wp-content/photos/2017/05/logo_black.png', | |
callToAction: { | |
default: | |
'Enjoy Lorem Ipsum without any ads for free or a little bit. Pay with Ethereum in just two clicks.', | |
}, | |
} | |
</script> | |
// Handle the events | |
<script> | |
/** | |
* Shows the Unlock checkout page | |
*/ | |
function loadCheckout() { | |
window.unlockProtocol && unlockProtocol.loadCheckoutModal() | |
} | |
/** | |
* Handles the events to lock/unlock! | |
*/ | |
window.addEventListener('unlockProtocol', function (e) { | |
var state = e.detail | |
if (state === 'locked') { | |
loadAds() | |
} else if (state === 'unlocked') { | |
hideAds() | |
} | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment