gImagesAttr

Adds dimension informations of the images on thumbnails in Google Images search

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         gImagesAttr
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds dimension informations of the images on thumbnails in Google Images search
// @author       cozen
// @include      http*://www.google.*/*tbm=isch*
// @include      http*://google.*/*tbm=isch*
// @include      https://www.google.*/search?tbm=isch*
// @include      https://google.*/search?tbm=isch*
// @include      https://www.google.co.*/*tbm=isch*
// @include      https://google.co.*/*tbm=isch*
// @grant        none
// ==/UserScript==

function addDimensions(node) {
    let owAtt = node.getAttribute("data-ow"),
        ohAtt = node.getAttribute("data-oh");

    let divAtt = document.createElement('div')
    divAtt.innerText = owAtt + " x " + ohAtt;
    divAtt.style.position = "absolute";
    divAtt.style.width = "50%";
    divAtt.style.color = "#FFF";
    divAtt.style.background = "#000";
    divAtt.style.fontSize = "8px";
    divAtt.classList.add("dimensions");
    divAtt.style.zIndex="+1";


    node.insertBefore(divAtt, node.firstElementChild);
}


(function() {
    'use strict';

    let observer = new MutationObserver( mutations => {
        for (let mutation of mutations) {
            for (let newNode of mutation.addedNodes) {
                addDimensions(newNode)
            }
        }
    });

    let container = document.querySelector(".islrc");
    for (let node of container.children) {
        addDimensions(node);
    }

    observer.observe(container, {childList: true});

})();