added paste-from-skype-history script

This commit is contained in:
Patrizio Bekerle 2017-06-06 12:10:27 +02:00
parent dc114d1e4f
commit 0152ba7cb8
No known key found for this signature in database
GPG Key ID: 2E9FFD770DABE838
2 changed files with 48 additions and 0 deletions

View File

@ -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."
}

View File

@ -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.*?>(.+?)<\/p>/gim;
var match;
while ((match = textRegExp.exec(html)) !== null) {
script.noteTextEditWrite(match[1].replace(/<.+?>/gim, "") + "\n");
}
}
}