From 87aaa9927617ef50fb6085c9db86e58ed44db082 Mon Sep 17 00:00:00 2001 From: Manuel Bouza Date: Thu, 28 Mar 2019 17:17:56 +0100 Subject: [PATCH] Parse description and projectId --- src/js/remoteServices.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/js/remoteServices.js b/src/js/remoteServices.js index c3476e0..6a6dff8 100644 --- a/src/js/remoteServices.js +++ b/src/js/remoteServices.js @@ -1,3 +1,5 @@ +const projectRegex = /^\[(\d+)\]/ + export default { asana: { name: "asana", @@ -29,7 +31,7 @@ export default { const match = document .querySelector(".js-issue-title") ?.textContent.trim() - ?.match(/^\[(\d+)\]/) + ?.match(projectRegex) return match && match[1] } }, @@ -70,7 +72,20 @@ export default { meistertask: { name: "meistertask", - urlPatterns: ["https\\://www.meistertask.com/app/task/:id/:slug"] + urlPatterns: ["https\\://www.meistertask.com/app/task/:id/:slug"], + description: document => { + const json = + document.getElementById("mt-toggl-data")?.dataset?.togglJson || "{}" + const data = JSON.parse(json) + return data.taskName + }, + projectId: document => { + const json = + document.getElementById("mt-toggl-data")?.dataset?.togglJson || "{}" + const data = JSON.parse(json) + const match = data.projectName?.match(projectRegex) + return match && match[1] + } }, trello: {