import QtQml 2.0 import com.qownnotes.noteapi 1.0 /** * This script creates a menu item and a button that parses the text that was copied * from a task webpage of the webservice bitrix24 and creates a new note with a headline, * the link to the task and the description */ QtObject { /** * Initializes the custom action */ function init() { // create a menu entry "New Bitrix note" with a button and a freedesktop theme icon script.registerCustomAction("newBitrixTaskNote", "New Bitrix task note", "Bitrix", "task-new"); } /** * This function is invoked when a custom action is triggered * in the menu or via button * * @param identifier string the identifier defined in registerCustomAction */ function customActionInvoked(identifier) { switch (identifier) { // create a new note from a Bitrix task webpage text in the clipboard // like from https://yourname.bitrix24.com/workgroups/group/10/tasks/task/view/150/ case "newBitrixTaskNote": // get the text that is currently in the clipboard var html = script.clipboard(true); // script.log(html); // https://regex101.com is your friend // var headlineRegExp = /(.+?)<\/span>/im; var headlineRegExp = /(.+?)<\/?span/im; var headlineMatch = headlineRegExp.exec(html); var headline = headlineMatch !== null ? headlineMatch[1] : ""; // remove the "aufgabe" text and all "/" headline = headline.replace("(aufgabe #", "(#").replace(/\s*\//igm, ""); if (headline == "") { script.informationMessageBox("No Bitrix task headline was found!", "Bitrix task note"); return; } // add the task id to the headline var taskIdRegExp = /