Advertisement
Guest User

Fix Special Characters in Image Titles on Twenty Sided

a guest
Apr 5th, 2015
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Fix Special Characters in Image Titles
  3. // @namespace    http://cjk.net.au
  4. // @version      0.1
  5. // @description  Replaces wordpress-mangled special html entities on Twenty Sided (http://www.shamusyoung.com/twentysidedtale/)
  6. // @author       CJ Kerr
  7. // @match        http://www.shamusyoung.com/twentysidedtale/*
  8. // @grant        none
  9. // @require       http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  10. // ==/UserScript==
  11.  
  12. // Replace Malformed Unicode entities
  13. this.$ = this.jQuery = jQuery.noConflict(true);
  14.  
  15. $(document).ready(function()
  16. {
  17.     $("img").each(function(index) {
  18.        
  19.         var altText = $(this).attr("title");
  20.        
  21.         if (altText != undefined) {
  22.             var newAltText = altText.replace(/’/g, "\u2019").replace(/“/g, "\u201C").replace(/”/g, "\u201D");
  23.             $(this).attr("title", newAltText);
  24.         }
  25.        
  26.     });
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement