G+ avatar comeback

Google+评论头像修改

  1. // ==UserScript==
  2. // @name G+ avatar comeback
  3. // @namespace undefineds
  4. // @version 2.0
  5. // @description Google+评论头像修改
  6. // @author saifu nekura
  7. // @require https://code.jquery.com/jquery-3.2.1.slim.min.js
  8. // @match *://plus.google.com/*
  9. // @grant unsafeWindow
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. var contents = 'content';
  16. var storage = window.localStorage;
  17. // var gb_Nc = document.querySelector("body").classList.contains("gb_9c");
  18.  
  19. //地区转换,默认HK
  20. //var changelink = 'https://plus.google.com/?gl=HK';
  21. // var bool = window.location.href == "https://plus.google.com/" || window.location.href == "https://plus.google.com/u/0/" && document.getElementsByClassName("gb_b")[0].href == 'https://www.google.cn/intl/zh-CN/options/';
  22. //if(bool) window.location.href = changelink;
  23. //默认头像
  24. var defaultHead = "//lh3.googleusercontent.com/image/-n-0L5nvI570/AAAAAAAAAAI/AAAAAAAAAAA/V0sHAqXP4pk/s60-p-k-no/photo.jpg";
  25. //最大头像数量
  26. var headNum = 5000;
  27.  
  28. var selectStyle=document.createElement("style");
  29. 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('"+defaultHead+"');float: left; background-size: 24px!important;}.nk-postHead img {width: 24px; height: 24px; border-radius:50%; }.lbkpOc {line-height: 24px!important; }.SVRkP {max-height:42px!important; display: block!important;}";
  30. document.getElementsByTagName("head")[0].appendChild(selectStyle);
  31.  
  32. $(function(){
  33. //动态日志
  34. //
  35. // $('.Nb2Prf').append('<a class="M9kDrd" track:click" href="https://plus.google.com/apps/activities" target="_blank"><div class="CjySve">Activities</div></a>');
  36.  
  37. function writeHead(img,name){
  38. if(window.localStorage){
  39. storage[name] = img;
  40. if(storage.length > headNum) {
  41. storage.removeItem(storage.key(storage.length/2));
  42. }
  43. }
  44. }
  45.  
  46.  
  47. function isLocalStorage() {
  48. var testKey = 'test',
  49. storage = window.localStorage;
  50. try {
  51. storage.setItem(testKey, 'testValue');
  52. storage.removeItem(testKey);
  53. return true;
  54. } catch (error) {
  55. return false;
  56. }
  57. }
  58.  
  59. if(isLocalStorage()){
  60. $(document).on('DOMSubtreeModified', contents, function (e) {
  61. $('div.SVRkP').each(function(){
  62. var name = $(this).find(".vGowKb").html();
  63. if($(this).find('bdo').length == 0){
  64. $(this).prepend("<bdo class='nk-postHead'></bdo>");
  65. }else if(name != null) {
  66. var newHead = storage[name];
  67. if(newHead != null) $(this).find('.nk-postHead').css('background','url("'+newHead+'")');
  68. }
  69. });
  70. $("div.Ihwked").on('click',function(){
  71. setTimeout(function(){
  72. $("li.BCNiN").each(function(){
  73. var imgs = $(this).find("img").attr('src');
  74. var names = $(this).find(".vGowKb").html();
  75. // if(storage.getItem(names) == null){
  76. writeHead(imgs,names);
  77. // }
  78. });
  79. },1200);
  80. });
  81.  
  82. });
  83. }else{
  84. alert("来自G+ avatar comeback 浏览器不支持localStorage");
  85. }
  86. //if(bool && !$("div").hasClass("gb_Nc")) window.location.href = changelink;
  87. });
  88.  
  89. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址