Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TorilPow
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description shows how to use babel compiler
  6. // @author You
  7. // @require https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js
  8. // @require https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js
  9. // @require http://code.jquery.com/jquery-3.4.1.min.js
  10. // @match https://toril.pl/*
  11. // ==/UserScript==
  12.  
  13. const soundurl = 'http://www.chiptape.com/chiptape/sounds/medium/countdown.wav';
  14.  
  15. // We are logged in if we have topbar.
  16. function getstatus(wit){
  17. let wits = [];
  18. if(wit.length){
  19. // alert('We have top bar!');
  20. for(let i=0;i<wit.length;i++){
  21. //console.log($(wit[i]).attr('style') + ' ' + $(wit[i]).attr('class'));
  22. if($(wit[i]).hasClass('wit1')){
  23. wits[0] = ($(wit[i]).attr('style').indexOf('wit2.png') == -1) ? 0: 1;
  24. }
  25. else if ($(wit[i]).hasClass('wit2')){
  26. wits[1] = ($(wit[i]).attr('style').indexOf('wit4.png') == -1) ? 0: 1;
  27. }
  28. else if ($(wit[i]).hasClass('wit3')){
  29. wits[2] = ($(wit[i]).attr('style').indexOf('wit8.png') == -1) ? 0: 1;
  30. }
  31. else if ($(wit[i]).hasClass('wit4')){
  32. wits[3] = ($(wit[i]).attr('style').indexOf('wit6.png') == -1) ? 0: 1;
  33. }
  34. }
  35. }
  36. return wits;
  37. }
  38.  
  39. var player = document.createElement('audio');
  40. player.src = soundurl;
  41. player.preload = 'auto';
  42.  
  43. $('body').append('<div id="informacjalewy" style="background-color: #22bb11; position: fixed; color: #000000; line-height: 50px;' +
  44. 'top:0px; left:0px; z-index=99; width:150px; height: 50px; text-align: center; valign: middle; display: none;">Nowe!</div>');
  45.  
  46. function getajaxstatus(){
  47. $.ajax ( {
  48. type: 'GET',
  49. url: 'https://toril.pl/kp.php',
  50. success: function(data) {
  51. var doc = document.documentElement.cloneNode();
  52. doc.innerHTML = data;
  53. let newwit = $(doc.querySelectorAll('div.wit'));
  54. let sitewit = $('div.wit');
  55. let curwits = getstatus(sitewit);
  56. let newwits = getstatus(newwit);
  57. for(let i=0;i<curwits.length;i++){
  58. if(curwits[i] === 0 && newwits[i] === 1){
  59. $('div#informacjalewy').show();
  60. document.title = 'NOWY POST NA TELENOWERILU ONEELEVEN!';
  61. player.play();
  62. }
  63. }
  64. }
  65. });
  66. }
  67. getajaxstatus();
  68. var intid = setInterval(getajaxstatus, 30000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement