oo.pe redirection remover

remove oo.pe redirection in Arca.live

目前為 2024-04-09 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name            oo.pe redirection remover
// @name:ko         oo.pe 리디렉션 제거기
// @namespace       OOPE_REMOVER_V1
// @match           https://arca.live/b/*
// @run-at          document-end
// @version         1.2
// @author          Laria
// @description     remove oo.pe redirection in Arca.live
// @description:ko  아카라이브 oo.pe 리디렉션을 제거합니다.
// @supportURL      https://greasyfork.org/scripts/485591
// @icon            https://www.google.com/s2/favicons?sz=64&domain=oo.pe
// @license         MIT
// @encoding        utf-8
// ==/UserScript==

/*
 * Note: Please install with greasyfork, it will update automatically..
 *
 * More info. https://greasyfork.org/scripts/485591
 *
*/

/*
 * == Change log ==
 * 1.0 - release
 * 1.1 - add retry
 * 1.2 - detect comment reload
 */

//root
(function() {
    'use strict';
    function resolveLink(tar = document) {
      //search link include 'oo.pe'
      tar.querySelectorAll('a[href*="oo.pe"]').forEach(function(src) {
        try {
          //tokenizing
          const token = src.href.split('/');
          //search oo.pe prefix
          const pref = token.indexOf('oo.pe');
          //join link after prefix
          const out = token.slice(pref + 1).join('/');
          //apply
          src.href = out;
        } catch (_) {}
      });
    }
    resolveLink();
    //repeat resolve and add event listner
    setTimeout(() => {
      resolveLink();
    }, 50);
    setTimeout(() => {
      resolveLink();
      //resolve link when comment reload
      document.querySelector('.article-comment').querySelector('.newcomment-alert').addEventListener('click', (event) => {
        event.preventDefault();
        for (let i = 1; i <= 7; i++) {
          setTimeout(function() {
            resolveLink(document.querySelector('.article-comment'));
          }, 100 * i);
        }
      });
    }, 200);
})();