GameFAQs WebM Support

WebM Support for GameFAQs Forums

  1. // ==UserScript==
  2. // @name GameFAQs WebM Support
  3. // @namespace Kraust
  4. // @description WebM Support for GameFAQs Forums
  5. // @include *.gamefaqs.com/boards/*
  6. // @version 0.5.0
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10.  
  11. /****************************************************************************
  12. * Please Note: The URL parsing on this is not 100%. Some characters *
  13. * (namely ()'s) will not parse. *
  14. ****************************************************************************/
  15.  
  16.  
  17. $('td.msg').each(function() {
  18. var text = $(this).html();
  19. var regex = /http:\/\/[^"]*\.webm|https:\/\/[^"]*\.webm/g;
  20. var matches = regex.exec(text);
  21. while(matches = regex.exec(text)) {
  22. var text = $(this).html();
  23. if ( matches !== null) {
  24. if ( matches !== null) {
  25. if( matches !== undefined) {
  26. console.log(matches);
  27. var video_regex = new RegExp('<a href="' + matches + '">' + matches + '<\/a>');
  28. console.log(video_regex);
  29. $(this).html(text.replace(video_regex, '<video width=\"720\" height=\"480\" controls ><source src=\"' + matches[0] + '\" type=\'video/webm; codecs=\"vp8, vorbis\"\'></video>'));
  30. }
  31. }
  32.  
  33. }
  34. }
  35. });
  36.  
  37.  
  38. // /<a href="http:\/\/.*\.webm">http:\/\/.*\.webm<\/a>/