您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
jianshu Markdown preview AUTO scroll
当前为
// ==UserScript== // @name Jianshu MD AUTO Scroll // @name:zh-CN 简书 Markdown 预览同步滚动 // @namespace jianshu // @include *://www.jianshu.com/writer* // @version 1.0.1 // @description jianshu Markdown preview AUTO scroll // @description:zh-CN 给简书的在线 Markdown 编辑器增加输入预览同步滚动的功能 // @author BlindingDark // @grant none // ==/UserScript== // (function() { 'use strict'; // Your code here... //text mousetrap span6 preview function jQuery_start(){ var txtMain; var spPreview; function tampermonkey_start(){ txtMain = $('.text.mousetrap')[0]; spPreview = $('.span6.preview')[0]; txtMain.onscroll=function(){ spPreview.scrollTop = Math.round((txtMain.scrollTop + txtMain.clientHeight) * spPreview.scrollHeight / txtMain.scrollHeight - spPreview.clientHeight); }; spPreview.onscroll=function(){ txtMain.scrollTop = Math.round((spPreview.scrollTop + spPreview.clientHeight) * txtMain.scrollHeight / spPreview.scrollHeight - txtMain.clientHeight); }; } function tampermonkey_wait(){ if ((txtMain = $('.text.mousetrap')[0])===undefined) { window.setTimeout(tampermonkey_wait,1000); } else { if ((spPreview = $('.span6.preview')[0])===undefined){ window.setTimeout(tampermonkey_wait,1000); } else { tampermonkey_start(); } } } tampermonkey_wait(); //TODO 点击预览按钮重新设置监听 } function Tampermonkey_jQuery_wait(){ if(typeof jQuery == 'undefined') { window.setTimeout(Tampermonkey_jQuery_wait,1000); console.log("waiting for jQuery prepared"); } else { $ = jQuery; console.log("jQuery ready"); jQuery_start(); } } Tampermonkey_jQuery_wait(); })();