Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ async function scrap() {
return await runScrapper(tab, options);
}

async function openInRows(message: { data: string; }) {
const tab = await getCurrentTab();

if (!tab || !tab.url || !tab.title) {
return;
}

const tabUrl = tab.url;

chrome.tabs.create({ url: 'https://rows.com/new' }, (tab) => {
return storeRowsXData(message.data, tab.id!).then(() => reportUsage({ action: 'open_in_Rows', url: tabUrl }));
});
}

async function storeRowsXData(tsv: string, tabId: number) {
await chrome.scripting.executeScript({
target: { tabId },
Expand All @@ -39,9 +53,7 @@ chrome.runtime.onMessage.addListener((message, _, sendResponse) => {
scrap().then((data) => sendResponse(data));
break;
case 'rows-x:store':
chrome.tabs.create({ url: 'https://rows.com/new' }, (tab) => {
return storeRowsXData(message.data, tab.id!).then(() => reportUsage({action: 'open_in_Rows'}));
});
openInRows(message);
break;
default:
break;
Expand Down
5 changes: 3 additions & 2 deletions src/utils/rows-api/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import UAParser from 'ua-parser-js';

interface ReportUsageParams {
action: 'copy_values' | 'open_in_Rows';
url?: string;
}

export async function createNewReportEntryRow(feedback? : string) {
Expand Down Expand Up @@ -42,8 +43,8 @@ export async function reportUsage(params: ReportUsageParams): Promise<void> {

const row_cells = [
new Date(),
tab.url,
new URL(tab.url!).hostname,
params.url ? params.url : tab.url,
new URL(params.url ? params.url : tab.url!).hostname,
userAgent.getBrowser().name,
userAgent.getBrowser().version,
action,
Expand Down