Advertisement
Guest User

Untitled

a guest
Jul 5th, 2018
308
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* PLEASE READ
  2.  
  3. This code was written by mzrt for use at musikchan.com and was not originally intended for release
  4. Please realize that this code may be less than professional grade
  5.  
  6. You are free to use this code for anything legal as long as you:
  7. 1. take all responsibility for the effects of this code
  8. 2. leave this disclaimer
  9. 3. leave all references to musikchan.com
  10. 4. consider sending me a message at m0zart@musikchan.com or join our discord at https://discord.gg/MxVFf77
  11.  
  12. */
  13.  
  14. $(document).ready(function() {
  15. var ytLinks = $('a[href^="https://youtu.be/"]').filter(function() {
  16. return this.innerHTML.match(/(https:\/\/youtu.be\/)([\S]{11})/);
  17. });
  18. $(ytLinks).each(function(index) {
  19.  
  20. var x = null;
  21. var id = $(this).attr("href").split("be/")[1];
  22. var e = $('<a class="embed" id="' + id + index +'" href="#"> [embed]</a>').insertAfter($(this));
  23. e.click(function(evt) {
  24. evt.preventDefault();
  25. if (x != 1) {
  26. $(this).after('<div id="ytEmbed_' + id + '_' + index + '"><iframe width="560" height="315" src="https://youtube.com/embed/' + id + '" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen ></iframe></div>')
  27. $(e).html('<a class="embed" id="' + id + index +'" href="#"> [remove]</a>')
  28. x = 1;
  29. } else {
  30. $('#ytEmbed_' + id + '_' + index).detach();
  31. $(e).html('<a class="embed" id="' + id + index +'" href="#"> [embed]</a>')
  32. x = null;
  33. console.log('ytEmbed_' + id + '_' + index);
  34. }
  35.  
  36. });
  37.  
  38. });
  39. });
Advertisement
RAW Paste Data Copied
Advertisement