复制标题网址(QQ群:189574683)

复制当前页面标题及网址

目前为 2021-02-24 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 复制标题网址(QQ群:189574683)
  3. // @namespace https://www.wdssmq.com
  4. // @author 沉冰浮水
  5. // @version 2.0
  6. // @description 复制当前页面标题及网址
  7. // @url https://gf.qytechs.cn/zh-CN/scripts/28056
  8. // @link ----------------------------
  9. // @link https://github.com/wdssmq/userscript
  10. // @link https://afdian.net/@wdssmq
  11. // @link https://gf.qytechs.cn/zh-CN/users/6865-wdssmq
  12. // @link ----------------------------
  13. // @include http://*
  14. // @include https://*
  15. // @grant GM_registerMenuCommand
  16. // @grant GM_setClipboard
  17. // jshint esversion:6
  18. // ==/UserScript==
  19.  
  20. (function () {
  21. /* jshint multistr:true */
  22. "use strict";
  23. if (window.frames.length != parent.frames.length) {
  24. // alert('在iframe中');
  25. return false;
  26. }
  27. function fnGetInfo(md = false) {
  28. let url = document.location.href.replace("?tdsourcetag=s_pctim_aiomsg", "");
  29. url = url.replace("?from=manga_person", "");
  30. let title = document.title.trim();
  31. title = title.replace(/^(.+吧-百度贴吧)--.+/, "$1");
  32. if (md) {
  33. title = title.replace(/([_\[\]])/g, "\\$1");
  34. }
  35. if (location.host == "gf.qytechs.cn") {
  36. url = url.replace(/(\/\d+)-.+/, "$1");
  37. }
  38. return [title, url];
  39. }
  40.  
  41. GM_registerMenuCommand("复制", () => {
  42. const [title, url] = fnGetInfo();
  43. GM_setClipboard(title + "\n" + url);
  44. });
  45.  
  46. GM_registerMenuCommand("复制HTML", () => {
  47. const [title, url] = fnGetInfo();
  48. GM_setClipboard(
  49. `<p>${title}</p><p><a href="${url}" target="_blank" title="${title}">${url}</a></p>`
  50. );
  51. });
  52.  
  53. GM_registerMenuCommand("复制为Markdown[text]", () => {
  54. const [title, url] = fnGetInfo(true);
  55. GM_setClipboard(`[${title}](${url} "${title}")`);
  56. });
  57.  
  58. GM_registerMenuCommand("复制为Markdown[link]", () => {
  59. const [title, url] = fnGetInfo(true);
  60. GM_setClipboard(`${title}:\n\n[${url}](${url} "${title}")`);
  61. });
  62.  
  63. function $n(e) {
  64. return document.querySelector(e);
  65. }
  66. function $na(e) {
  67. return document.querySelectorAll(e);
  68. }
  69. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址