Skip to content

Instantly share code, notes, and snippets.

@hsayed21
Last active June 22, 2024 07:06
Show Gist options
  • Save hsayed21/288fce3d49fb0d68ba03f05ee11ca73f to your computer and use it in GitHub Desktop.
Save hsayed21/288fce3d49fb0d68ba03f05ee11ca73f to your computer and use it in GitHub Desktop.
Odoo Auto Sort By Column
// ==UserScript==
// @name Odoo Auto Sort
// @namespace http://tampermonkey.net/
// @version 1.0
// @description try to take over the world!
// @author @hsayed21
// @match https://www.posbank.me/web
// @icon https://www.google.com/s2/favicons?sz=64&domain=posbank.me
// @updateURL https://gist.github.com/hsayed21/288fce3d49fb0d68ba03f05ee11ca73f.js
// @downloadURL https://gist.github.com/hsayed21/288fce3d49fb0d68ba03f05ee11ca73f.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
let intervalId; // Variable to hold the interval ID
function startAutoSort(sortSelector) {
const sortElement = document.querySelector(sortSelector);
if (sortElement)
{
try
{
const ariaSortValue = sortElement.getAttribute('aria-sort');
if (ariaSortValue !== 'ascending') {
sortElement.click();
clearInterval(intervalId);
setTimeout(startInterval, 4000);
}
}
catch (error) {
console.error(error.message);
}
}
}
// Function to start the interval
function startInterval() {
intervalId = setInterval(() => {
startAutoSort("th[data-name='sla_deadline']");
}, 2000);
}
// Usage
try {
startInterval();
} catch (error) {
console.error(error.message);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment