🏠 返回首頁 

Greasy Fork is available in English.

OFFLINE ALERT

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


Installer dette script?
  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. 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;}");
  21. function offNotice(e){
  22. var d = document.createElement("div");
  23. d.id = "offlinenotice";
  24. d.style.height = window.innerHeight + "px";
  25. d.style.width = window.innerWidth + "px";
  26. d.appendChild(document.createTextNode("OFFLINE"));
  27. document.body.appendChild(d);
  28. }
  29. function removeNotice(e){
  30. var d = document.getElementById("offlinenotice");
  31. if (d) d.parentNode.removeChild(d);
  32. }
  33. document.body.addEventListener("offline", offNotice, false);
  34. document.body.addEventListener("online", removeNotice, false);
  35. function offNotice(e){
  36. var d = document.createElement("div");
  37. d.id = "offlinenotice";
  38. d.style.height = window.innerHeight + "px";
  39. d.style.width = window.innerWidth + "px";
  40. d.appendChild(document.createTextNode("OFFLINE"));
  41. document.body.appendChild(d);
  42. // Hide Flash players
  43. var players = document.querySelectorAll("object, embed");
  44. for (var i=0; i<players.length; i++){
  45. if (players[i].hasAttribute("type")){ if (players[i].getAttribute("type") == "application/x-shockwave-flash"){
  46. if (window.getComputedStyle(players[i],null).getPropertyValue("visibility") == "visible"){
  47. players[i].style.visibility = "hidden";
  48. players[i].setAttribute("offlinehidden", "yes");
  49. }
  50. }}
  51. }
  52. }
  53. function removeNotice(e){
  54. var d = document.getElementById("offlinenotice");
  55. if (d) d.parentNode.removeChild(d);
  56. // Restore Flash players
  57. var restoreset = document.querySelectorAll("object[offlinehidden], embed[offlinehidden]");
  58. for (var i=0; i<restoreset.length; i++){
  59. restoreset[i].style.visibility = "visible";
  60. restoreset[i].removeAttribute("offlinehidden");
  61. }
  62. }