Created
December 28, 2023 13:52
-
-
Save alanhe421/2a9da42326559c455fe9a4e6094471d4 to your computer and use it in GitHub Desktop.
拼多多脚本,方便发送消息
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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