Facebook Image Alt Text Display

Display automated alt text over images.

  1. // ==UserScript==
  2. // @name Facebook Image Alt Text Display
  3. // @namespace http://
  4. // @version 0.1
  5. // @description Display automated alt text over images.
  6. // @author Marko Zabreznik
  7. // @require http://code.jquery.com/jquery-1.11.0.min.js
  8. // @match https://www.facebook.com/
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. function debounce (func, threshold) {
  14. var timeout;
  15. var obj = this;
  16. function delayed () {
  17. func.apply(obj);
  18. timeout = null;
  19. }
  20. return function () {
  21. if (timeout)
  22. clearTimeout(timeout);
  23. timeout = setTimeout(delayed, threshold);
  24. };
  25. }
  26.  
  27. function showAlt() {
  28. $("#contentArea img[alt]:not(.fimah).img").each(function(){
  29. var img = $(this);
  30. img.addClass('fimah');
  31. if (img.hasClass('UFIActorImage') || !img.attr('alt') || img.attr('alt') == "No automatic alt text available.") {
  32. return;
  33. }
  34. $('<div style="position:absolute;bottom: 0; padding: 4px; left: 0;background:rgba(255,255,255,0.5); color: black;"></div>')
  35. .text(img.attr('alt')).insertAfter(this);
  36. });
  37. }
  38.  
  39. new MutationObserver(debounce(showAlt, 200)).observe(document, {subtree: true, childList: true});

QingJ © 2025

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