Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
simple webpage that notify user with free ebook from Packtpub
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>PackPub free ebook notifier</title>
</head>
<body>
<?php
require('simple_html_dom.php');
$page = file_get_html('https://www.packtpub.com/packt/offers/free-learning');
$ebook_title = '';
foreach ($page->find('div[class=dotd-title]') as $value)
{
$ebook_title = preg_replace('/\s+/', ' ', $value->plaintext);
}
?>
<script>
window.onload = notifyMe;
function notifyMe(){
if (!("Notification" in window)){
alert("This browser does not support desktop notification");
}
else if (Notification.permission === "granted"){
var notification = new Notification("Today free ebook is" + '<?php echo $ebook_title; ?>');
}
else if (Notification.permission !== "denied"){
Notification.requestPermission(function(permission){
if(permission === "granted"){
var notification = new Notification("Today free ebook is" + '<?php echo $ebook_title; ?>');
}
});
}
}
</script>
<p id="ebook-name">
Tody free e-book from PacktPub is <?php echo $ebook_title; ?>
</p>
</body>
</html>
@cosminpopescu14

This comment has been minimized.

Copy link
Owner Author

@cosminpopescu14 cosminpopescu14 commented Feb 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.