AAAAA-复制标题-到memory.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // ==UserScript==
  2. // @name AAAAA-复制标题-到memory
  3. // @namespace Violentmonkey Scripts
  4. // @icon https://memory.tianyunperfect.cn/pro_icon.svg
  5. // @match *://*/*
  6. // @grant GM_registerMenuCommand
  7. // @version 1.0
  8. // @author tianyunperfect
  9. // @require https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js
  10. // @require https://git.tianyunperfect.cn/tianyunperfect/web-base/raw/master/tmp/monkey/util.js?a=1
  11. // @description 2021/1/30 下午7:09:51
  12. // ==/UserScript==
  13. (function () {
  14. 'use strict';
  15. GM_registerMenuCommand("!!!复制并加到memory", to_memory)
  16. GM_registerMenuCommand("!!!复制标题和 url", copyTitle)
  17. function to_memory() {
  18. let url = location.href;
  19. let title = document.title;
  20. if (window.self !== window.top) {
  21. return
  22. }
  23. let body = {
  24. "back": "<p></p>",
  25. "front": `<p>url: <a href="${url}">${title}</a></p>`,
  26. "period": 0,
  27. "onlyText": "",
  28. "remindTime": new Date(),
  29. "tag": "",
  30. "updateTime": "",
  31. "userId": 1
  32. };
  33. let memory_url = "https://memory.tianyunperfect.cn/api/memory-64B206F1-E915-4298-9AB7-9C561040B012/insert";
  34. axios.post(memory_url, body).then((res) => {
  35. console.log(res.data);
  36. let data = res.data;
  37. if (data.success) {
  38. } else {
  39. alert(data.message);
  40. }
  41. })
  42. myAlert(`${title}<br/>${location.host}`, 2)
  43. }
  44. function copyTitle() {
  45. myCopy(`<a href="${location.href}">${document.title}</a>`)
  46. }
  47. unsafeWindow.to_memory = to_memory;
  48. document.onkeydown = function (ev) {
  49. if (ev.key === 'c' && ev.shiftKey) {
  50. ev.preventDefault() // 关闭浏览器快捷键
  51. copyTitle()
  52. }
  53. }
  54. })();