谷歌相册按钮扩展(最近添加按钮、未保存的建议)

给谷歌相册增加了两个按钮,一个用来展示最近上传的图片,一个用来展示没有保存/关闭掉的个性化建议

  1. // ==UserScript==
  2. // @name Buttons for Google Photos
  3. // @name:zh-CN 谷歌相册按钮扩展(最近添加按钮、未保存的建议)
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.1
  6. // @description Add recent button to show recent upload photos, and unsaved button to show unsaved recommend.
  7. // @description:zh-CN 给谷歌相册增加了两个按钮,一个用来展示最近上传的图片,一个用来展示没有保存/关闭掉的个性化建议
  8. // @author You
  9. // @match https://photos.google.com/*
  10. // @author oraant
  11. // @grant none
  12. // @require http://code.jquery.com/jquery-3.4.1.min.js
  13. // ==/UserScript==
  14.  
  15. (function() {
  16.  
  17. // 获取按钮组
  18. var button_list = $('.R4TmW:first');
  19.  
  20. // 创建分割线
  21. var hr = $("<hr class='iBSb1b dBapkc DOAbib eZnXWb' style='margin-left:10px;margin-right:15px;'>");
  22.  
  23. // 创建“最近添加的照片”按钮removeClass
  24. var button_recent = $(button_list.children()[0]).clone(); // 复制一个按钮
  25. $(button_recent).attr("data-location","1001"); // 防止被激活高亮
  26. $(button_recent).removeClass("ixImeb"); // 去掉激活按钮的类名
  27. $(button_recent).find(".OOX9bc:first").text("最近添加"); // 改文字
  28. $(button_recent).find(".FKF6mc:first").attr("href","/search/_tra_"); // 改链接
  29. $(button_recent).find("path").attr("d","M16.24 7.76C15.07 6.59 13.54 6 12 6v6l-4.24 4.24c2.34 2.34 6.14 2.34 8.49 0 2.34-2.34 2.34-6.14-.01-8.48zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"); // 该图标
  30.  
  31. // 创建“未保存的建议”按钮
  32. var button_unsaved = $(button_list.children()[0]).clone();
  33. $(button_unsaved).attr("data-location","1002");
  34. $(button_unsaved).removeClass("ixImeb");
  35. $(button_unsaved).find(".OOX9bc:first").text("仍未保存");
  36. $(button_unsaved).find(".FKF6mc:first").attr("href","/unsaved");
  37. $(button_unsaved).find("path").attr("d","M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3zm3-10H5V5h10v4z");
  38.  
  39. // 将创建的元素添加到页面中
  40. button_list.append(hr, button_recent, button_unsaved);
  41. })();