OFFLINE ALERT

When in Work Offline Mode, the webpage you are on will display OFFLINE to alert you that you are in Offline Mode.

  1. // ==UserScript==
  2. // @name OFFLINE ALERT
  3. // @author Written by Jefferson Scher
  4. // @namespace Requested by *Barbiegirl* (thread http://userscripts.org/topics/91003)(thankyou Jefferson)
  5. // @description When in Work Offline Mode, the webpage you are on will display OFFLINE to alert you that you are in Offline Mode.
  6. // @version 1.0
  7. // @include http://*
  8. // @include https://*
  9. // @include *
  10. // @include about:blank
  11. // @include about:newtab
  12. // @include about:*
  13. // @include data:image/*
  14. // @include file:///*
  15. // @include file:*
  16. // @include file:///C:/Users/*
  17. // @include file:///*
  18. // @include file:///*.PNG
  19. // ==/UserScript==
  20.  
  21.  
  22. GM_addStyle("#offlinenotice{position:fixed!important;top:0!important;left:0!important;background:#ccc!important;opacity:0.95!important;padding:25% 0!important;text-align:center!important;z-index:999!important;color:#CC0000!important;font-family:verdana!important;font-size:10em!important;}");
  23.  
  24. function offNotice(e){
  25. var d = document.createElement("div");
  26. d.id = "offlinenotice";
  27. d.style.height = window.innerHeight + "px";
  28. d.style.width = window.innerWidth + "px";
  29. d.appendChild(document.createTextNode("OFFLINE"));
  30. document.body.appendChild(d);
  31. }
  32.  
  33. function removeNotice(e){
  34. var d = document.getElementById("offlinenotice");
  35. if (d) d.parentNode.removeChild(d);
  36. }
  37.  
  38. document.body.addEventListener("offline", offNotice, false);
  39. document.body.addEventListener("online", removeNotice, false);
  40.  
  41. function offNotice(e){
  42. var d = document.createElement("div");
  43. d.id = "offlinenotice";
  44. d.style.height = window.innerHeight + "px";
  45. d.style.width = window.innerWidth + "px";
  46. d.appendChild(document.createTextNode("OFFLINE"));
  47. document.body.appendChild(d);
  48. // Hide Flash players
  49. var players = document.querySelectorAll("object, embed");
  50. for (var i=0; i<players.length; i++){
  51. if (players[i].hasAttribute("type")){ if (players[i].getAttribute("type") == "application/x-shockwave-flash"){
  52. if (window.getComputedStyle(players[i],null).getPropertyValue("visibility") == "visible"){
  53. players[i].style.visibility = "hidden";
  54. players[i].setAttribute("offlinehidden", "yes");
  55. }
  56. }}
  57. }
  58. }
  59.  
  60. function removeNotice(e){
  61. var d = document.getElementById("offlinenotice");
  62. if (d) d.parentNode.removeChild(d);
  63. // Restore Flash players
  64. var restoreset = document.querySelectorAll("object[offlinehidden], embed[offlinehidden]");
  65. for (var i=0; i<restoreset.length; i++){
  66. restoreset[i].style.visibility = "visible";
  67. restoreset[i].removeAttribute("offlinehidden");
  68. }
  69. }