1. Open a new tab with .tab async interface
warp.tab async method gives you a simple API to control page behavior. The tab promise resolves when the DOMLoaded event is triggered in the tab’s web page. The simplest way to open a tab is by passing a URL as the first parameter.
let tab = await warp.tab("https://google.com");
2. Create a tab and inspect it
warp.tab returns a promise which returns a Tab object;
We can inspect this object.
let t = await warp.tab("https://index.hr"); warp.inspect(t);
3. Open a new tab with specific ID
By passing an ID in options, we can retrieve this tab later. For convenience, the first parameter can also be an options object containing the “url” property.
let tab = await warp.tab('https://nyt.com', { id: 'myTab' });
let tab2 = await warp.tab({ url: 'https://duckduckgo.com', id: 'myTab2' });
4. Open several tabs and close them when loaded
tab.destroy() will remove the tab from the browser.
5. Retrieve tab by its ID and navigate to a new URL
We can retrieve a tab by using its ID as argument to warp.tab.
let tab = await warp.tab({ url: "https://google.com", id: "exampleTab" }); let anotherReference = await warp.tab("exampleTab"); await anotherReference.navigate("https://google.com/search?q=warp+browser");
6. Retrieve active tab and destroy it
We can get the active tab ID from warp.native.activeTab.
if (tabs[warp.native.activeTab]) { let activeTab = await warp.tab(warp.native.activeTab); activeTab.destroy(); } else { toast("No Tab is active right now"); }
7. Close all tabs
Warp stores everything in warp.lists.
Tabs are in warp.lists.native.tabs.
each(warp.lists.native.tabs, async function(id, tab) {
tab.destroy();
});
8. Change agent on active tab
You can get or set Agent on the tab with .agent() method
let tab = await warp.tab(warp.native.activeTab); tab.agent("Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36")
9.Open best Facebook group in tab
The best group is AI Hrvatska;
we will open it in a tab.
let tab = await warp.tab("https://www.facebook.com/groups/aihrvatska");
10. Open web of the best browser in the world in a new window 500×800 as mobile
You can work with windows through native invoking pipeline; notice the upper case use for classes and methods.
let winId = "w23698x2"; await warp.invoke("Windows", "Create", [winId]); await warp.invoke("Windows", "Show", [winId]); await warp.invoke("Windows", "Width", [winId, 500]); await warp.invoke("Windows", "Height", [winId, 800]); let tab = await warp.tab({ url : "https://warpbrowser.com", id : "t23698", win : winId }); tab.agent("Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36")
11. Open Warp’s LinkedIn page
Open Warp browser’s company LinkedIn page in a tab
let tab = await warp.tab("
https://www.linkedin.com/company/warpbrowser/
");