Last active
June 22, 2024 07:06
-
-
Save hsayed21/288fce3d49fb0d68ba03f05ee11ca73f to your computer and use it in GitHub Desktop.
Odoo Auto Sort By Column
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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