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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // ==UserScript==
  2. // @name AAAAA-复制标题-到memory
  3. // @namespace Violentmonkey Scripts
  4. // @icon https://memory.tianyunperfect.cn/pro_icon.svg
  5. // @match *://*/*
  6. // @exclude https://memory.tianyunperfect.cn/*
  7. // @exclude https://tracert.alipay.com/*
  8. // @exclude https://t.captcha.qq.com/*
  9. // @grant GM_registerMenuCommand
  10. // @version 1.0
  11. // @author tianyunperfect
  12. // @require https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js
  13. // @require http://www.tianyunperfect.cn:3001/tianyunperfect/web-base/raw/master/tmp/monkey/util.js
  14. // @description 2021/1/30 下午7:09:51
  15. // ==/UserScript==
  16. (function () {
  17. 'use strict';
  18. GM_registerMenuCommand("!!!复制并加到memory", to_memory)
  19. GM_registerMenuCommand("!!!复制标题和 url", copyTitle)
  20. function to_memory() {
  21. let url = location.href;
  22. let title = document.title;
  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. if (window.confirm(`${title}\n${location.host}\n`)) {
  34. let memory_url = "https://memory.tianyunperfect.cn/api/memory-64B206F1-E915-4298-9AB7-9C561040B012/insert";
  35. axios.post(memory_url, body).then((res) => {
  36. console.log(res.data);
  37. let data = res.data;
  38. if (data.success) {
  39. } else {
  40. alert(data.message);
  41. }
  42. })
  43. }
  44. }
  45. function copyTitle() {
  46. myCopy(`<a href="${location.href}">${document.title}</a>`)
  47. }
  48. document.onkeydown = function (ev) {
  49. if (ev.key === 'c' && ev.shiftKey) {
  50. ev.preventDefault() // 关闭浏览器快捷键
  51. copyTitle()
  52. }
  53. }
  54. })();