mirror of
https://github.com/marty-oehme/scripts.git
synced 2024-12-22 07:58:08 +00:00
added paste-from-skype-history script
This commit is contained in:
parent
dc114d1e4f
commit
0152ba7cb8
2 changed files with 48 additions and 0 deletions
9
paste-from-skype-history/info.json
Normal file
9
paste-from-skype-history/info.json
Normal 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."
|
||||||
|
}
|
39
paste-from-skype-history/paste-from-skype-history.qml
Normal file
39
paste-from-skype-history/paste-from-skype-history.qml
Normal 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue