Greasy Fork

Greasy Fork is available in English.

G+ avatar comeback

Google+评论头像修改

当前为 2017-10-02 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         G+ avatar comeback
// @namespace    undefineds
// @version      0.1
// @description  Google+评论头像修改
// @author       saifu nekura
// @require      https://code.jquery.com/jquery-3.2.1.slim.min.js
// @match        *://plus.google.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
     var selectStyle=document.createElement("style");
    selectStyle.innerHTML=".yB586c {width:48px!important;}.z5rWI {font-size: 12px!important; }.z5rWI span {display: block; width:100%;}.PvmUkc {visibility: hidden; margin-top:0px!important; }.OnSI9b:hover .PvmUkc{visibility: visible;}.BCNiN {padding: 12px 16px!important; padding-bottom: 0px!important;}.PvmUkc .JSaIGb {width: 18px!important; height: 18px!important;}.nk-postHead {width:24px; height: 24px; border-radius: 50%; margin-right: 5px; background: url(https://lh3.googleusercontent.com/image/-n-0L5nvI570/AAAAAAAAAAI/AAAAAAAAAAA/V0sHAqXP4pk/s40-p-k-rw-no/photo.jpg);float: left; background-size: 24px;}.nk-postHead img {width: 24px; height: 24px; border-radius:50%; }.lbkpOc {line-height: 24px!important; }.SVRkP {max-height:42px!important; display: block!important;}";
    document.getElementsByTagName("head")[0].appendChild(selectStyle);
$(function(){
var contents = 'content';
var storage = window.localStorage;
    //最大头像数量
var headNum = 5000;
    //默认头像
var defaultHead = "https://lh3.googleusercontent.com/image/-n-0L5nvI570/AAAAAAAAAAI/AAAAAAAAAAA/V0sHAqXP4pk/s60-p-k-rw-no/photo.jpg";

$(document).on('DOMSubtreeModified', contents, function (e) {
	 $('div.SVRkP').each(function(){
	 		var vg = $(this).find(".vGowKb").html();
	 	if($(this).find('bdo').length == 0){
	 		$(this).prepend("<bdo class='nk-postHead'></bdo>");
	 	}else if(vg != null && $(this).find('img').length == 0) {
	 		defaultHead = storage[vg];
	 		if(defaultHead != null) $(this).find('bdo').append("<img src='"+defaultHead+"'/>");
	 	}
 });
 $("div.Ihwked").on('click',function(){
	setTimeout(function(){
       	$("li.BCNiN").each(function(){
	       	var imgs = $(this).find("img").attr('src');
	      	var names = $(this).find(".vGowKb").html();
	      	if(storage.getItem(names) == null){
	      	writeHead(imgs,names);
	      	}
       	});
	},1200);
	});
});
function writeHead(img,name){
		if(window.localStorage){
            storage[name] = img;
             if(storage.length > headNum) {
                 storage.removeItem(storage.key(storage.length/2));
             }
        }
}
});
})();