Simple Print LeetCode Problems

Removed unnecessary elements in the page for a clear PDF print of the leetcode question only

As of 2017-05-01. See the latest version.

  1. // ==UserScript==
  2. // @name Simple Print LeetCode Problems
  3. // @namespace https://greatest.deepsurf.us/en/users/114838-groundzyy
  4. // @version 0.2
  5. // @description Removed unnecessary elements in the page for a clear PDF print of the leetcode question only
  6. // @author groundzyy
  7. // @match https://leetcode.com/problems/*
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12. $(document).ready(function() {
  13. var diff = $('.question-info > ul li:nth-child(5)').text();
  14. $('#tab-view-app').remove();
  15. $('#add-to-favorite').remove();
  16. $('.question-info').remove();
  17. $('.notepad-wrapper').remove();
  18. $('#interviewed-div').remove();
  19. $('section.action').remove();
  20. $('div.ng-scope').remove();
  21. $('div.navbar').remove();
  22. $('#submission-form-app').remove();
  23. // $('footer').remove();
  24. $('#chat-link').remove();
  25. $('span.hidebutton').css('display', 'inline');
  26. $('#tags').remove();
  27. $('#similar').remove();
  28. $('a.btn-primary').css('border', '1px solid silver');
  29. $('a.btn-primary').removeAttr("href");
  30. $('a[href="/subscribe/"]').parent().remove();
  31. $('head title').text($('.question-title > h3').text().trim().replace('.', ''));
  32. $('body').css('font-size', '28px');
  33. $('pre').css('font-size', '22px');
  34. $('a.btn-primary').css('font-size', '20px');
  35. // $('a.btn-primary').parent().parent().css('margin-top', '10px');
  36. $('div.question-title h3').css('font-size', '32px');
  37. $('p').css('margin-bottom', '28px');
  38. $('p').css('margin-top', '28px');
  39. $('footer').remove();
  40. $('div.content-wrapper').append('<hr style="margin-top:100px;"/>');
  41. $('div.content-wrapper').append('<div><span class="hidebutton" style="display: inline;"> <a class="btn btn-xs btn-primary" style="border: 1px solid silver; font-size: 20px;">' + diff + '</a></span></div>');
  42. $('div.content-wrapper').append($('a.btn-primary').parent().parent());
  43. $('pre').css('white-space', 'pre-wrap');
  44. $('pre').css('font-size', '28px');
  45. $('.question-content').css('line-height', '42px');
  46. $('.showspoilers').remove();
  47. $('div.spoilers').css('display', 'block');
  48. $('div.spoilers').css('margin-top', '100px');
  49. $('div.spoilers').css('font-size', '20px');
  50. $("b:contains('Credits:')").parent().remove();
  51. });
  52. })();