Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. // ==UserScript==
  2. // @name mal_extra
  3. // @description extra functions for MAL scripts
  4. // @version 1.2.2
  5. // @author akarin
  6. // ==/UserScript==
  7.  
  8. var Fancybox = function(prefix) {
  9. this.body = $();
  10. this.outer = $();
  11. this.wrapper = $();
  12.  
  13. this.init = function(el) {
  14. this.body = $('<div id="' + prefix + '_fancybox_inner"></div>');
  15. this.outer = $('<div id="' + prefix + '_fancybox_outer"></div>');
  16. this.wrapper = $('<div id="' + prefix + '_fancybox_wrapper"></div>');
  17. this.outer.hide().append(this.body).insertAfter(el);
  18. this.wrapper.hide().click(this.close).insertAfter(el);
  19. };
  20.  
  21. this.start = function(onstart) {
  22. this.body.children().hide();
  23. if (onstart()) {
  24. this.wrapper.show();
  25. this.outer.show();
  26. }
  27. else {
  28. this.close();
  29. }
  30. };
  31.  
  32. this.close = function() {
  33. this.outer.hide();
  34. this.wrapper.hide();
  35. };
  36. };
  37.  
  38. String.prototype.formatJapTitle = function() {
  39. return this
  40. .replace(/\s+/g, ' ')
  41. .replace(/[\uff01-\uff5e]/g, function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); })
  42. .replace(/\s?,\s?/g, '、')
  43. .replace(/\s?\+\s?/g, '+')
  44. .replace(/\s?=\s?/g, '=')
  45. .replace(/[“”]/g, '"')
  46. .replace(/\s?-\s?/g, '-')
  47. .replace(/\s?:\s?/g, ':').replace(/(\d):(\d)/g, '$1:$2')
  48. .replace(/\s?[\(〈]/g, '(').replace(/[\)〉]\s?/g, ')')
  49. .replace(/\s?[\[【]/g, '[').replace(/[\]】]\s?/g, ']')
  50. .replace(/\s?『/g, '「').replace(/』\s?/g, '」')
  51. .replace(/\//g, '/').replace(////g, '//').replace(/\s?/\s?/g, '/')
  52. .replace(/[\.。]/g, '.').replace(/\s?.\s?/g, '.')
  53. .replace(/;/g, ';').replace(/\s?;\s?/g, ';')
  54. .replace(/["“”]/g, '"').replace(/\s?"\s?/g, '"')
  55. .replace(/[.・]{3}/g, '…').replace(/^./g, '.')
  56. .replace(/([^\w])./g, '$1。').replace(/(\d).(\d)/g, '$1.$2')
  57. .replace(/!/g, '!').replace(/\s?!\s?/g, '!')
  58. .replace(/\?/g, '?').replace(/\s??\s?/g, '?')
  59. .replace(/[~〜]/g, '~').replace(/\s?~\s?/g, '~')
  60. .replace(/([^\w]|[\sA-Z])x([^\w]|[\sA-Z])/g, '$1 × $2')
  61. .replace(/\s?×\s?/g, ' × ').replace(/\s?x\s?/g, ' × ');
  62. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement