From 0152ba7cb8229d69850312b54b8aa5030c4ba9db Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Tue, 6 Jun 2017 12:10:27 +0200 Subject: [PATCH] added paste-from-skype-history script --- paste-from-skype-history/info.json | 9 +++++ .../paste-from-skype-history.qml | 39 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 paste-from-skype-history/info.json create mode 100644 paste-from-skype-history/paste-from-skype-history.qml diff --git a/paste-from-skype-history/info.json b/paste-from-skype-history/info.json new file mode 100644 index 0000000..44d2b5c --- /dev/null +++ b/paste-from-skype-history/info.json @@ -0,0 +1,9 @@ +{ + "name": "Paste text from Skype history", + "identifier": "paste-from-skype-history", + "script": "paste-from-skype-history.qml", + "authors": ["@pbek"], + "version": "0.0.1", + "minAppVersion": "17.05.6", + "description" : "This script creates a menu item and a button that parses the text that was copied from the Skype Electron client to the clipboard and tries to extract and paste text from it." +} diff --git a/paste-from-skype-history/paste-from-skype-history.qml b/paste-from-skype-history/paste-from-skype-history.qml new file mode 100644 index 0000000..04635bd --- /dev/null +++ b/paste-from-skype-history/paste-from-skype-history.qml @@ -0,0 +1,39 @@ +import QtQml 2.0 +import QOwnNotesTypes 1.0 + +/** + * This script creates a menu item and a button that parses the text that was copied from the Skype Electron client + * to the clipboard and tries to extract and paste text from it + */ +QtObject { + /** + * Initializes the custom action + */ + function init() { + // create a menu entry with a button and a freedesktop theme icon + script.registerCustomAction("pasteFromSkypeHistory", "Paste text from Skype history", "Paste Skype Text", "edit-paste"); + } + + /** + * 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) { + if (identifier != "pasteFromSkypeHistory") { + return; + } + // get the text that is currently in the clipboard + var html = script.clipboard(true); + +// script.log(html); + + var textRegExp = /(.+?)<\/p>/gim; + var match; + + while ((match = textRegExp.exec(html)) !== null) { + script.noteTextEditWrite(match[1].replace(/<.+?>/gim, "") + "\n"); + } + } +}