|
@@ -0,0 +1,59 @@
|
|
|
+// ==UserScript==
|
|
|
+// @name MinDoc 扩展脚本
|
|
|
+// @namespace http://tampermonkey.net/
|
|
|
+// @version 0.1
|
|
|
+// @description 个人笔记--京东脚本;
|
|
|
+// @author westinyang
|
|
|
+// @match http://westinyang.top:6010/docs/*
|
|
|
+// @match http://192.168.1.160:6010/docs/*
|
|
|
+// @icon http://westinyang.top:6010/favicon.ico
|
|
|
+// @grant none
|
|
|
+// ==/UserScript==
|
|
|
+
|
|
|
+(function() {
|
|
|
+ 'use strict';
|
|
|
+
|
|
|
+ // 个人笔记--京东脚本
|
|
|
+ window["_docs_mylib_ff84f3afb91f2ac899ac61bfd423d343"] = function() {
|
|
|
+ var str = "";
|
|
|
+ var arr = $("pre.hljs:eq(1)").text().split("\n");
|
|
|
+ for (var i in arr) {
|
|
|
+ if (arr[i].startsWith("pt_key")) {
|
|
|
+ str += arr[i] + "&";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ str = str.substring(0, str.length - 1);
|
|
|
+ console.log("JD_COOKIE", str);
|
|
|
+ }
|
|
|
+
|
|
|
+ // ====================================================================================================
|
|
|
+
|
|
|
+ // 封装自定义事件
|
|
|
+ const bindHistoryEvent = function(type) {
|
|
|
+ const historyEvent = history[type];
|
|
|
+ return function() {
|
|
|
+ const newEvent = historyEvent.apply(this, arguments); // 执行history函数
|
|
|
+ const e = new Event(type); // 声明自定义事件
|
|
|
+ e.arguments = arguments;
|
|
|
+ window.dispatchEvent(e); // 抛出事件
|
|
|
+ return newEvent; // 返回方法,用于重写history的方法
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ // 重写history原有的方法
|
|
|
+ history.pushState = bindHistoryEvent('pushState');
|
|
|
+ history.replaceState = bindHistoryEvent('replaceState');
|
|
|
+
|
|
|
+ // 监听事件
|
|
|
+ window.addEventListener('replaceState', historyStateChange);
|
|
|
+ window.addEventListener('pushState', historyStateChange);
|
|
|
+ function historyStateChange(e) {
|
|
|
+ var funcName = location.pathname.replaceAll("/", "_");
|
|
|
+ console.log(location.pathname, funcName);
|
|
|
+ //console.log(window[funcName]);
|
|
|
+ if (window[funcName]) {
|
|
|
+ window[funcName]();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ historyStateChange({});
|
|
|
+})();
|