Created
April 23, 2020 14:04
-
-
Save popstas/3d2e94a3a04df271d9146fe1ed010921 to your computer and use it in GitHub Desktop.
Расширение отправляет задачи из 2 списков в планировщике Планфикса в json файл
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$filename = 'planfix-tasks.json'; | |
if($_POST['tasks']) { | |
file_put_contents($filename, $_POST['tasks']); | |
return; | |
} | |
$lists = json_decode(file_get_contents($filename)); | |
foreach($lists as $listName => $data) { | |
echo "<b>$data->name</b>"; | |
echo '<ul>'; | |
foreach($data->tasks as $task) { | |
echo "<li>$task->name</li>"; | |
} | |
echo '</ul>'; | |
} | |
?> | |
<style> | |
ul { margin: 0 0 10px; padding: 0; } | |
ul li { | |
padding: 0; | |
list-style: none; | |
} | |
ul li:before { | |
content: ' - '; | |
} | |
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Planfix task list | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Send task list from planner to remote server | |
// @author popstas | |
// @match https://popstas.planfix.ru/?action=planner | |
// @grant GM_xmlhttpRequest | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var u = 'undefined'; | |
var win = typeof unsafeWindow != u ? unsafeWindow : window; | |
var $ = win.$; | |
var postUrl = "https://path/to/planfix-task-list.php | |
function sendTasks() { | |
console.log('send tasks'); | |
var lists = { | |
today: { | |
filter_id: 50086, | |
}, | |
week: { | |
filter_id: 50216 | |
} | |
} | |
var listNames = Object.keys(lists); | |
listNames.forEach(listName => { | |
var list = lists[listName]; | |
var planner = $('[data-taskfilterid="' + list.filter_id + '"]'); | |
var tasks = planner.find('.b-task-microcard'); | |
var data = tasks.map((ind, task) => { | |
return { | |
name: $('.task-microcard-title > a', task).text() | |
}; | |
}).toArray(); | |
lists[listName].tasks = data; | |
lists[listName].name = planner.find('.planner-block-name').text(); | |
}); | |
var raw = encodeURI(JSON.stringify(lists)); | |
console.log(raw); | |
GM_xmlhttpRequest ({ | |
method: "POST", | |
url: postUrl, | |
data: "tasks="+raw, | |
headers: { | |
"Content-Type": "application/x-www-form-urlencoded" | |
} | |
}); | |
} | |
setInterval(sendTasks, 600000); | |
setTimeout(sendTasks, 5000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment