OneTime layout saver

Save and restore column layouts for OneTime

2017-12-05 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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");