Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chrome插件能否支持发送剪切板中的磁链 #475

Closed
rdcentermrzhi opened this issue Mar 11, 2024 · 8 comments · Fixed by #492
Closed

chrome插件能否支持发送剪切板中的磁链 #475

rdcentermrzhi opened this issue Mar 11, 2024 · 8 comments · Fixed by #492
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@rdcentermrzhi
Copy link

Describe the background

Describe the feature

@gitautomator gitautomator bot added enhancement New feature or request question Further information is requested labels Mar 11, 2024
@qingchoulove
Copy link
Collaborator

Hello,能更详细描述下你的需求么?为什么还需要发送剪切板中的磁链,插件是支持直接把网页内容发送到Kubespider的呀。

@richardli1598
Copy link
Contributor

是这种场景吗,比如qq desktop发了个链接,你复制一下,然后鼠标右键发送触发下载?

@rdcentermrzhi
Copy link
Author

Hello,能更详细描述下你的需求么?为什么还需要发送剪切板中的磁链,插件是支持直接把网页内容发送到Kubespider的呀。

这个插件不能将网页中的文本内容直接发送吧、比如磁力链接直接显示在网页中只提供了一个copy选项 没有做超链接 就没法发送

@richardli1598
Copy link
Contributor

理解了,这个确实没支持

@qingchoulove
Copy link
Collaborator

Hello,能更详细描述下你的需求么?为什么还需要发送剪切板中的磁链,插件是支持直接把网页内容发送到Kubespider的呀。

这个插件不能将网页中的文本内容直接发送吧、比如磁力链接直接显示在网页中只提供了一个copy选项 没有做超链接 就没法发送

好的,我大致明白啦,我们近期会调研一下插件捕获内容的处理方式。非常感谢你的建议

@rdcentermrzhi
Copy link
Author

Hello,能更详细描述下你的需求么?为什么还需要发送剪切板中的磁链,插件是支持直接把网页内容发送到Kubespider的呀。

这个插件不能将网页中的文本内容直接发送吧、比如磁力链接直接显示在网页中只提供了一个copy选项 没有做超链接 就没法发送

好的,我大致明白啦,我们近期会调研一下插件捕获内容的处理方式。非常感谢你的建议

本来想自己搞一下,但是nodejs 确实不懂, 环境搞了一上午没弄起来,npm run dev 在windows 上会提示一个
image
这个路径就很奇怪, 不知道是哪里环境配置的问题, 有时间可以考虑支持一下, 多谢

@richardli1598
Copy link
Contributor

richardli1598 commented Mar 11, 2024

看了下,chrome extension v3应该不支持类似操作,实现代码如下(kubespider-extension/src/backgroud.js,模仿https://github.com/extend-chrome/clipboard/blob/master/src/index.ts):

import {
  consumer,
  sender,
  MessageType,
  Reply,
  SuccessReply,
  ErrorReply,
} from "@message";
import Notification from "@message/notification";
import { api, downloadRequest } from "@api";
import Storage from "@storage";
import { Tab, Cookies } from "@bridge";
import Browser from "webextension-polyfill";

/**
 * create context menu
 */
Browser.runtime.onInstalled.addListener(() => {
  Browser.contextMenus.create({
    id: "KubespiderLinkMenu",
    title: "Send to Kubespider",
    contexts: ["all"],
  });
  Browser.contextMenus.create({
    id: "KubespiderClipboardMenu",
    title: "Send clipboard link to Kubespider",
    contexts: ["all"],
  });
});

/**
 * handle context menu click
 */
Browser.contextMenus.onClicked.addListener(async (info, tab) => {
  let dataSource = ""
  switch (info.menuItemId) {
    case "KubespiderMenu": {
      let dataSource = info.linkUrl;
      if (dataSource === "" || dataSource == null) {
        dataSource = tab?.url;
      }
      break
    }
    case "KubespiderClipboardMenu": {
      const el = document.createElement('textarea')
      el.value = 'before paste'
      document.body.append(el)

      // Paste from clipboard into input
      el.select()
      document.execCommand('paste')

      // The contents of the clipboard
      const text = el.value
      el.remove()
      console.log(text);
      break
    }
  }
 ...

会存在如下报错:
image

根据这个FAQ: https://www.reddit.com/r/learnjavascript/comments/rqr5eg/document_is_not_defined/

v3应该不支持了。

建议从这里拷贝内容,然后触发下载:
image

@qingchoulove
Copy link
Collaborator

@rdcentermrzhi 我们为插件添加了选中文本的支持,现在会首先发送选中文本到服务端。可以重装插件看下能否满足诉求。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants