Something Awful Image-Domain On Hover

Displays the domain of images on hover.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           Something Awful Image-Domain On Hover
// @namespace      http://www.mathemaniac.org
// @include        *://forum.somethingawful.com/showthread.php?*
// @include        *://forums.somethingawful.com/showthread.php?*
// @include        *://archives.somethingawful.com/showthread.php?*
// @description    Displays the domain of images on hover.
// @version        1.1.1
// @grant          none
// ==/UserScript==

// Change for v1.1.1, June 6th, 2016: Support https.
// Change for v1.1.0, December 9th, 2012: Handle attachments.
// Change for v1.0.1, August 6th, 2011: Handle timgs.

var imgs = document.getElementsByTagName('img');
for (var i = 0; i < imgs.length; i++) {
    var curImg = imgs[i];
    if (curImg.classList.contains('img') || curImg.classList.contains('timg')) {
        var domain = curImg.getAttribute('src').match(/https?:\/\/([^\/]+)\//);
        if (domain) {
            curImg.setAttribute('title', domain[1]);
        } else {
            console.log("SA Image-Domain On Hover: Couldn't determine location of '" + curImg.getAttribute('src') + "'.");
        }
    } else if (curImg.parentNode.classList.contains('attachment')) {
        curImg.setAttribute('title', '[attachment]');
    }
}