screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3.2.12/dist/vue.global.js"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script> </head> <body> <div id="app"> <h3>Vue Js Detect Adblocker</h3> <div v-if="!adBlock"> <div class="container"> <h2>It looks like you're using an ad-blocker</h2> <p> We use ads to keep our content happy and free. Please support us by whitelisting. </p> <div class="container text-center text-md-center ad-blocker"> <h3>TURN OFF YOUR AD-BLOCKER AND RELOAD THE PAGE</h3> </div> </div> </div> <div v-else> <p>Our Site Content</p> </div> </div> <script type="module"> const app = Vue.createApp({ data() { return { adBlock: true, // Initialize with true, assuming ad blocker is active }; }, beforeMount() { axios .get( "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" ) .then(() => { this.adBlock = true; }) .catch(() => { this.adBlock = false; }); }, }); app.mount("#app"); </script> <style scoped> .container { max-width: 600px; margin: 0 auto; padding: 20px; border-radius: 5px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } .text-center { text-align: center; } .text-md-center { text-align: center; } h2 { font-size: 24px; margin-bottom: 10px; } h3 { font-size: 18px; margin-bottom: 10px; } p { margin-top: 0; } .ad-blocker { background-color: #ffc107; color: #212529; padding: 20px; margin-top: 20px; border-radius: 5px; } /* Media query for small screens */ @media (max-width: 576px) { .container { max-width: 100%; padding: 10px; } } </style> </body> </html>