Advertisement
Guest User

Untitled

a guest
Aug 13th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.48 KB | None | 0 0
  1. #!/bin/bash
  2. dir='secret'
  3. function xmlgetnext(){
  4.     local IFS='>'
  5.     read -d '<' TAG VALUE
  6. }
  7.  
  8. function rssget(){
  9.     cp /dev/null "${dir}news.html"
  10.     curl -s "$1" | while xmlgetnext ; do
  11.         case "$TAG" in
  12.             'title')
  13.                 title="$VALUE"
  14.                 ;;
  15.             'link')
  16.                 link="$VALUE"
  17.                 ;;
  18.         esac
  19.         [[ $oldlink != "$link" ]] && echo "<a target='_blank' href='${link}'>${title}</a> <img src='IMG/tux.png' height='16' width='16'> " >> "${dir}news.html"
  20.         oldlink="$link"
  21.     done
  22.     rssdata="$(sort -u "${dir}news.html" | tail -n+2)"
  23.     echo "$rssdata"
  24. }
  25.  
  26. linux_news="$(rssget 'https://www.linux.com/feeds/rss')"
  27. hacker_news="$(rssget 'https://news.ycombinator.com/rss')"
  28.  
  29. printf '<!DOCTYPE html>
  30.  <head>
  31.    <style>
  32.      a:link {
  33.        text-decoration: none;
  34.        color: black;
  35.      }
  36.      a:visited {
  37.        text-decoration: none;
  38.        color: black;
  39.      }
  40.    </style>
  41.    <script type="text/javascript">
  42.      window.addEventListener("wheel", function(e) {
  43.        if (e.deltaY < 0) {
  44.          document.getElementById("marq").setAttribute("scrolldelay", "10");
  45.        }
  46.        if (e.deltaY > 0) {
  47.          document.getElementById("marq").setAttribute("scrolldelay", "55");
  48.        }
  49.      });
  50.    </script>
  51.  </head>
  52.  <body>
  53.    <marquee id="marq" scrolldelay="55" truespeed="1">%s%s</marquee>
  54.  </body>' "${linux_news}" "${hacker_news}" > "${dir}news.html"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement