OneTime layout saver

Save and restore column layouts for OneTime

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        OneTime layout saver
// @description Save and restore column layouts for OneTime
// @namespace   https://greasyfork.org/en/users/814-bunta
// @version     1.1
// @include     https://onetime.onedatacom.com/*
// @run-at      document-end
// @noframes
// @nowrap
// @libraries   
// @grant       GM_getValue
// @grant       GM_setValue
// ==/UserScript==

console.log("script start");

var $ = unsafeWindow.$;
var widths1 = JSON.parse(GM_getValue("savedWidths1", "[30,215,250,80,240,70,65,40]"));
var widths2 = JSON.parse(GM_getValue("savedWidths2", "[30,215,250,80,240,70,65,40]"));

function loadFavouritesColumnLayout() {
  $("div#onejobgrid colgroup").each(function() {
    $(this).children().each(function(i) {
      $(this).removeAttr('style').css("width",widths1[i]+"px");
    });
  });
  
  $("div#buFavgrid colgroup").each(function() {
    $(this).children().each(function(i) {
      $(this).removeAttr('style').css("width",widths2[i]+"px");
    });
  });

}

function addSaveButton() {
  var elem = document.getElementById("saveLayoutBtn"); 
  elem.onclick = saveFavouritesColumnLayout;
}

function saveFavouritesColumnLayout() {
  var widthSettings = [];
  $("div#onejobgrid colgroup").first().children().each(function(i) {
    widthSettings.push($(this).width());
  });
  
  GM_setValue("savedWidths1", JSON.stringify(widthSettings));

  var widthSettings = [];
  $("div#buFavgrid colgroup").first().children().each(function(i) {
    widthSettings.push($(this).width());
  });
  
  GM_setValue("savedWidths2", JSON.stringify(widthSettings));
}

loadFavouritesColumnLayout();
addSaveButton();

console.log("script finish");