OFFLINE ALERT

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           OFFLINE ALERT
// @author         Written by Jefferson Scher
// @namespace      Requested by *Barbiegirl* (thread http://userscripts.org/topics/91003)(thankyou Jefferson)
// @description    When in Work Offline Mode, the webpage you are on will display OFFLINE to alert you that you are in Offline Mode.
// @version        1.0
// @include        http://*
// @include        https://*
// @include        *
// @include        about:blank
// @include        about:newtab
// @include        about:*
// @include        data:image/*
// @include        file:///*
// @include        file:*
// @include        file:///C:/Users/*
// @include        file:///*
// @include        file:///*.PNG
// ==/UserScript==


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;}");

function offNotice(e){
  var d = document.createElement("div");
  d.id = "offlinenotice";
  d.style.height = window.innerHeight + "px";
  d.style.width = window.innerWidth + "px";
  d.appendChild(document.createTextNode("OFFLINE"));
  document.body.appendChild(d);
}

function removeNotice(e){
  var d = document.getElementById("offlinenotice");
  if (d) d.parentNode.removeChild(d);
}

document.body.addEventListener("offline", offNotice, false);
document.body.addEventListener("online", removeNotice, false);

function offNotice(e){
  var d = document.createElement("div");
  d.id = "offlinenotice";
  d.style.height = window.innerHeight + "px";
  d.style.width = window.innerWidth + "px";
  d.appendChild(document.createTextNode("OFFLINE"));
  document.body.appendChild(d);
  // Hide Flash players
  var players = document.querySelectorAll("object, embed");
  for (var i=0; i<players.length; i++){
    if (players[i].hasAttribute("type")){ if (players[i].getAttribute("type") == "application/x-shockwave-flash"){
      if (window.getComputedStyle(players[i],null).getPropertyValue("visibility") == "visible"){
        players[i].style.visibility = "hidden";
        players[i].setAttribute("offlinehidden", "yes");
      }
    }}
  }
}

function removeNotice(e){
  var d = document.getElementById("offlinenotice");
  if (d) d.parentNode.removeChild(d);
  // Restore Flash players
  var restoreset = document.querySelectorAll("object[offlinehidden], embed[offlinehidden]");
  for (var i=0; i<restoreset.length; i++){
    restoreset[i].style.visibility = "visible";
    restoreset[i].removeAttribute("offlinehidden");
  }
}