Modify RES Image Title

Sets the title attribute on the RES Image in a Reddit thread to match the document title. This is done so extensions like Pinterest can capture the image and use the document's title as the description.

目前为 2015-12-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Modify RES Image Title
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Sets the title attribute on the RES Image in a Reddit thread to match the document title. This is done so extensions like Pinterest can capture the image and use the document's title as the description.
  6. // @author PoorPolonius
  7. // @include http://www.reddit.com/r/*
  8. // @include https://www.reddit.com/r/*
  9. // @match http://www.reddit.com/r/*
  10. // @match https://www.reddit.com/r/*
  11. // @grant GM_log
  12. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
  13. // @license Copyright 2015 reddit.com/u/PoorPolonius; Released under the MIT license
  14. // ==/UserScript==
  15. /* jshint -W097 */
  16. 'use strict';
  17.  
  18. // Your code here...
  19.  
  20. $(document).ready(function () {
  21.  
  22. var siteTable = "#siteTable",
  23. toggleButton = "a[class*='toggleImage']",
  24. resImage = "img[class*='RESImage']";
  25.  
  26. var toggleHandler = function (_evt) {
  27.  
  28. $(resImage).attr("title", document.title);
  29.  
  30. $(siteTable).undelegate(toggleButton, "click");
  31. };
  32.  
  33. $(siteTable).delegate(toggleButton, "click", toggleHandler);
  34. });