vdc pre code block converter

try to take over the pootis!

  1. // ==UserScript==
  2. // @name vdc pre code block converter
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.17
  5. // @description try to take over the pootis!
  6. // @author MrKleiner
  7. // @match https://developer.valvesoftware.com/wiki/*
  8. // @icon https://www.google.com/s2/favicons?domain=valvesoftware.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. function defer(method) {
  13. if (window.jQuery) {
  14. weready();
  15. } else {
  16. setTimeout(function() { defer(method) }, 100);
  17. }
  18. }
  19.  
  20. defer();
  21.  
  22. function weready()
  23. {
  24. $('#p-tb ul').append('<li><a id="call_pre_converter">Convert pre blocks</a></li>');
  25. $("#call_pre_converter").click(function(e){
  26. $(this).closest('li').remove();
  27. make_rows_hover();
  28. });
  29. }
  30.  
  31. function make_rows_hover()
  32. {
  33. $('body').append('<style>.liz3_vdc_line:hover{background:linear-gradient(0deg,rgba(0,0,0,.08) 0,rgba(0,0,0,.08) 100%)}</style>');
  34. $('.mw-parser-output pre').each(function(){
  35. var local_cont = $(this);
  36. var local_shit = $(this).text().split('\n');
  37. $(this).text('');
  38. for (var key in local_shit) {
  39. $(local_cont).append('<div class="liz3_vdc_line">' + local_shit[key] + '</div>');
  40. }
  41. });
  42. }