open_original_links_in_pocket

just open direct!

当前为 2020-01-07 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        open_original_links_in_pocket
// @namespace   undegro
// @include     https://app.getpocket.com/*
// @version     3.1
// @run-at      document-idle
// @license     MIT
// @description just open direct!
// ==/UserScript==

{
  const root = document.getElementById("root"),
        option = {childList: true, subtree: true},
        wait = new MutationObserver(records => records.forEach(r => r.addedNodes[0] && r.addedNodes[0].className.includes("rgmu9k") && start() ))
  console.log(1)

  wait.observe(root, option);


  function start() {
    wait.disconnect()
    console.log("b")
    const pocket = document.getElementsByClassName("css-17egg64")[0],
          options = {childList: true, subtree: true},
          mo = new MutationObserver(records => records.forEach(r => r.addedNodes[0] && change(r.addedNodes))),
          change = list => Array.from(list).filter(e => e.className.includes("5kqe7c"))
                             .forEach(e => {
                               let link = !e.getElementsByTagName("a")[2] ? e.getElementsByTagName("a")[0].href : e.getElementsByTagName("a")[2].href
                               e.getElementsByTagName("a")[0].href = e.getElementsByTagName("a")[1].href = decodeURIComponent(/\?url=(.*)/.exec(link)[1])
                             })

    mo.observe(pocket, options);

    change(pocket.getElementsByClassName("css-5kqe7c"));
  }
}