// ==UserScript==
// @name 135编辑器vip破解
// @namespace http://tampermonkey.net/
// @version 2025.2.20.1
// @description 无视 135 微信编辑器 VIP 限制,可以使用 VIP 排版
// @author Shuaima
// @match *://*.135editor.com/*
// @run-at document-end
// @grant unsafeWindow
// @require http://code.jquery.com/jquery-1.11.3.min.js
// ==/UserScript==
(function() {
'use strict';
// 配置对象,用于存储相关设置
const setting = {
item: null,
type: 1
};
// 添加自定义样式到页面
const addStyle = (cssText) => {
const style = document.createElement('style');
style.textContent = cssText;
(document.head || document.documentElement).appendChild(style);
};
// 插入 HTML 到编辑器的函数
const insertHtmlToEditor = (h) => {
const ue = unsafeWindow.top.UE.getEditor('WxMsgContent');
const range = ue.selection.getRange();
// 创建一个临时的 div 来解析插入的 HTML
const tempDiv = document.createElement('div');
tempDiv.innerHTML = h;
// 遍历临时 div 的子节点,依次插入到编辑器中
const childNodes = Array.from(tempDiv.childNodes);
let lastInsertedNode = null;
childNodes.forEach((node) => {
const clonedNode = node.cloneNode(true);
range.insertNode(clonedNode);
lastInsertedNode = clonedNode;
});
// 如果有插入节点,将光标定位到最后一个插入节点的后面
if (lastInsertedNode) {
// 确保节点是在文档树中
if (lastInsertedNode.parentNode) {
range.setStartAfter(lastInsertedNode);
range.setEndAfter(lastInsertedNode);
ue.selection.setRange(range);
}
}
};
// 135 编辑器的初始化函数
const init135 = () => {
// 创建“强势插入”按钮并添加点击事件
const insertButton = $('
VIP插入
').appendTo('body');
insertButton.on('click', () => {
if (!setting.item) return;
let html;
if (setting.type === 1) {
html = setting.item.find('._135editor').html();
} else if (setting.type === 2) {
html = setting.item.html();
unsafeWindow.window.top.$("#preview_modal_").hide();
}
if (html) {
insertHtmlToEditor(html);
}
});
// 监听鼠标移动事件
$("body").on('mousemove', (event) => {
const mouseX = event.pageX;
const mouseY = event.pageY;
let ele;
if ($(event.target).attr("id") === "template-modal") {
ele = $(event.target);
setting.type = 2;
setting.item = $(".l-img .Content-body");
insertButton.css({ left: 'auto', right: '20px', top: `${ele.offset().top + 50}px` }).show();
} else {
ele = $(event.target).parents('li.style-item').length > 0
? $(event.target).parents('li.style-item')
: $(event.target).parents('li.vip-style');
if (ele.length > 0) {
const { top: y1, left: x1 } = ele.offset();
const y2 = y1 + ele.height();
const x2 = x1 + ele.width();
if (mouseX < x1 || mouseX > x2 || mouseY < y1 || mouseY > y2) {
insertButton.hide();
setting.item = null;
} else {
setting.type = 1;
setting.item = ele;
insertButton.css({ left: `${x2 - 90}px`, top: `${y1 + 5}px` }).show();
}
} else {
if (!$(event.target).hasClass('wx_plus_btn')) {
insertButton.hide();
}
}
}
});
};
// 初始化函数
const init = () => {
if (window.location.host.search(/www.135editor.com/) >= 0) {
init135();
}
};
// 添加按钮的样式
addStyle(`
.wx_plus_btn{
position: absolute;
display: none;
left: 0;
top: 5px;
cursor: pointer;
width: 90px;
height: 30px;
line-height: 30px;
background: #f00;
color: #fff;
text-align: center;
z-index: 99999999;
}
`);
// 调用初始化函数
init();
})();