您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
監聽ACGN網頁變化並給予Addevent
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/33945/222879/ACGN-Stock%E8%82%A1%E7%A5%A8%E4%BA%8B%E4%BB%B6%E7%9B%A3%E8%81%BD.js
// ==UserScript== // @name ACGN-Stock股票事件監聽 // @namespace http://tampermonkey.net/ // @version 2.701 // @description 監聽ACGN網頁變化並給予Addevent // @author Ming // @match http://acgn-stock.com/* // @match https://acgn-stock.com/* // @grant none // ==/UserScript== // ==/UserScript== class BaseEvent { constructor(pattern) { this.pattern = pattern; this.callbacklist = []; } AddEventListner(callback) { this.callbacklist.push(callback); } RunCallback() { for (let i = 0; i < callbacklist.length; i++) { callbacklist[i](); } } CheckUrllState() { if (document.location.href.search(this.pattern) !== -1) { RunCallback(); } } } class Company extends BaseEvent { constructor() { super(/company\/detail/); } } class StockSummary extends BaseEvent { constructor() { super(/company\/[0-9]+/); } } class AccountInfo extends BaseEvent { constructor() { super(/accountInfo/); } } class Foundation extends BaseEvent { constructor() { super(/foundation\/[0-9]+/); } } class ACGNListener { constructor() { this.oldUrl = ""; this.company = new Company(); this.stockSummary = new StockSummary(); this.accountInfo = new AccountInfo(); this.foundation = new Foundation(); $("#main").bind("DOMNodeInserted DOMNodeRemoved", MainDivCheck); } MainDivCheck() { // 因AJAX動態生成不斷執行,所以有時候main的變動並不代表換頁,此時無須重新加入事件 if (this.oldUrl === document.location.href) return; oldUrl = document.location.href; //設定狀態 this.company.CheckUrllState(); this.stockSummary.CheckUrllState(); this.accountInfo.CheckUrllState(); this.foundation.CheckUrllState(); } AddCompanyListener(callback){ this.company.AddEventListner(callback); } AddStockSummaryListener(callback){ this.company.AddEventListner(callback); } AddAccountInfoListener(callback){ this.company.AddEventListner(callback); } AddFoundationListener(callback){ this.company.AddEventListner(callback); } }