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-06 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Modify RES Image Title
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  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 toggleButton = "a[class*='toggleImage']",
  23. resImage = "img[class*='RESImage']";
  24.  
  25. var toggleHandler = function (_evt) {
  26.  
  27. $(resImage).attr("title", document.title);
  28.  
  29. $(toggleButton).off(toggleHandler);
  30. };
  31.  
  32. $(toggleButton).on("click", toggleHandler);
  33. });