Hi, I just made up this code:
'use strict';
browser.browserAction.onClicked.addListener(function(aTab, event) {
async function test(){
let allTabs = await browser.tabs.query({});
//let newOrderTabs = new Array();
allTabs.sort(compareEqual);
console.log("allTabs should now be sorted!");
let allTabIds = allTabs.map((tabInfo) => tabInfo.id);
console.log("gooten ids array!");
let moving = browser.tabs.move(allTabIds, {index: 0});
console.log("all tabs should now have been moved!");
}
//run that code!
test();
//2 tabs.Tab objects are equal if their base url part and their title are the same
async function compareEqual(taba,tabb){
let urla=(new URL(taba.url)).hostname;
let urlb=(new URL(tabb.url)).hostname;
let titlea=taba.title;
let titleb=tabb.title;
let titleequal=titlea.localeCompare(titleb, 'en', { sensitivity: 'base' });
let urlequal=urla.localeCompare(urlb, 'en', { sensitivity: 'base' });
//<-1,=0,>1
if(urlequal!=0){return urlequal;}
else if(titleequal!=0){return titleequal;}
return 0;
}
});
what i intend it to do:
sort all tabs first by hostname, then by title.
and move tabs accordingly to their respective position.
I jsut tried running this, but It didnt do anything.
so I would assume that I am most likely lacking permissions.
Currently I only have tabs permission lsited in my manifest file, what other permissions woudl I need to do what I want here?