Fade In and Out

Adds fade out effect when the page is unloaded

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://www.wtfpl.net/ for more details. */

// ==UserScript==
// @name            Fade In and Out
// @namespace       http://userscripts.org/users/12
// @description     Adds fade out effect when the page is unloaded
// @version         3.0
// @author          LouCypher
// @license         WTFPL http://www.wtfpl.net/
// @homepageURL     https://userscripts.org/scripts/show/135732
// @resource        license https://raw.github.com/LouCypher/userscripts/master/licenses/WTFPL/LICENSE.txt
// @include         *
// @run-at          document-start
// @grant           GM_addStyle
// ==/UserScript==

GM_addStyle("@-moz-keyframes fadein {\
  from { opacity: 0; }\
  to   { opacity: 1; }\
}\
@-webkit-keyframes fadein {\
  from { opacity: 0; }\
  to   { opacity: 1; }\
}\
@keyframes fadein {\
  from { opacity: 0; }\
  to   { opacity: 1; }\
}\
html {\
     -moz-animation: fadein ease-in 1000ms;\
  -webkit-animation: fadein ease-in 1000ms;\
          animation: fadein ease-in 1000ms;\
}")

addEventListener("beforeunload", function() {
  GM_addStyle("@-moz-keyframes fadeout {\
  from { opacity: 1; }\
  to   { opacity: 0; }\
}\
@-webkit-keyframes fadeout {\
  from { opacity: 1; }\
  to   { opacity: 0; }\
}\
@keyframes fadeout {\
  from { opacity: 1; }\
  to   { opacity: 0; }\
}\
html {\
     -moz-animation: fadeout ease-in-out 500ms;\
  -webkit-animation: fadeout ease-in-out 500ms;\
          animation: fadeout ease-in-out 500ms;\
  opacity: 0;\
}");
}, false)