OneTime layout saver

Save and restore column layouts for OneTime

  1. // ==UserScript==
  2. // @name OneTime layout saver
  3. // @description Save and restore column layouts for OneTime
  4. // @namespace https://greasyfork.org/en/users/814-bunta
  5. // @version 1.1
  6. // @include https://onetime.onedatacom.com/*
  7. // @run-at document-end
  8. // @noframes
  9. // @nowrap
  10. // @libraries
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // ==/UserScript==
  14.  
  15. console.log("script start");
  16.  
  17. var $ = unsafeWindow.$;
  18. var widths1 = JSON.parse(GM_getValue("savedWidths1", "[30,215,250,80,240,70,65,40]"));
  19. var widths2 = JSON.parse(GM_getValue("savedWidths2", "[30,215,250,80,240,70,65,40]"));
  20.  
  21. function loadFavouritesColumnLayout() {
  22. $("div#onejobgrid colgroup").each(function() {
  23. $(this).children().each(function(i) {
  24. $(this).removeAttr('style').css("width",widths1[i]+"px");
  25. });
  26. });
  27. $("div#buFavgrid colgroup").each(function() {
  28. $(this).children().each(function(i) {
  29. $(this).removeAttr('style').css("width",widths2[i]+"px");
  30. });
  31. });
  32.  
  33. }
  34.  
  35. function addSaveButton() {
  36. var elem = document.getElementById("saveLayoutBtn");
  37. elem.onclick = saveFavouritesColumnLayout;
  38. }
  39.  
  40. function saveFavouritesColumnLayout() {
  41. var widthSettings = [];
  42. $("div#onejobgrid colgroup").first().children().each(function(i) {
  43. widthSettings.push($(this).width());
  44. });
  45. GM_setValue("savedWidths1", JSON.stringify(widthSettings));
  46.  
  47. var widthSettings = [];
  48. $("div#buFavgrid colgroup").first().children().each(function(i) {
  49. widthSettings.push($(this).width());
  50. });
  51. GM_setValue("savedWidths2", JSON.stringify(widthSettings));
  52. }
  53.  
  54. loadFavouritesColumnLayout();
  55. addSaveButton();
  56.  
  57. console.log("script finish");