Skip to content

Instantly share code, notes, and snippets.

@alanhg
Created December 28, 2023 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanhg/2a9da42326559c455fe9a4e6094471d4 to your computer and use it in GitHub Desktop.
Save alanhg/2a9da42326559c455fe9a4e6094471d4 to your computer and use it in GitHub Desktop.
拼多多脚本,方便发送消息
// ==UserScript==
// @name 拼多多增强脚本
// @namespace http://tampermonkey.net/
// @version 2023-12-28
// @description try to take over the world!
// @author Alan He
// @match https://mobile.yangkeduo.com/chat_detail.html*
// @icon https://www.google.com/s2/favicons?sz=64&domain=pinduoduo.com
// @grant none
// @run-at document-end
// ==/UserScript==
(function () {
'use strict';
const observer = new MutationObserver(function () {
const inputEl = document.querySelector('#input-content');
if (inputEl) {
bindKeyDownFn(inputEl);
}
});
const config = { childList: true, subtree: true };
observer.observe(document.body, config);
function bindKeyDownFn(el) {
el.placeholder = '回车键发送,Shift+回车键进行换行';
el.addEventListener('keydown', (e) => {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
document
.querySelector(
'#main > div > div.chat-input-provider > div > div.send-button'
)
.click();
}
});
observer.disconnect();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment