ao3 mark for later

Adds mark for later buttons to work index pages.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name    ao3 mark for later
// @description Adds mark for later buttons to work index pages. 
// @namespace   ao3
// @match       http*://archiveofourown.org/*works*
// @match       http*://archiveofourown.org/*bookmarks*
// @match       http*://archiveofourown.org/series/*
// @match       http*://archiveofourown.org/*readings*
// @match       http*://archiveofourown.org/collections*
// @match       http*://archiveofourown.org/users/*
// @exclude     http*://archiveofourown.org/*readings?*show=to-read*
// @grant       none
// @version     1.2
// ==/UserScript==

(function () {
  const blurbs = Array.from(document.querySelectorAll('li.blurb'));

  if (!blurbs.length) {
    return;
  }

  const style = document.createElement('style');

  style.innerHTML = `
    .blurb .mark {
      right: 0.5em;
      white-space: nowrap;
      test-align: center;
      clear: none;
      float: left;
      }

    @media only screen and (min-width: 800px) {
      .blurb .mark {
        right: 7em;
        top: 0.5em;
      }
    }
  `;

  document.head.appendChild(style);

  blurbs.forEach(blurb => {
    let workId;
    let notAO3;

    try {
      const titleLink = blurb.querySelector('.header.module .heading a');
      workId = (titleLink.href.match(/\/works\/(\d+)\b/) || [])[1];
      notAO3 = (titleLink.href.match(/archiveofourown.org/)||[]);
    } catch (ex) {
    }

    if (!workId || !notAO3[0]) {
      console.log('[ao3 mark for later] - skipping blurb that isn\'t a work blurb: ', blurb);
      return;
    }

    let section = blurb.querySelector('.actions')
    console.log(!section)
      if(!section)
      {
          section = blurb
      }

    section.innerHTML += `
      <div class="mark">
        <ul class="actions" role="menu">
              <li>
                <a href=https://archiveofourown.org/works/${workId}/mark_for_later>Mark for Later</a>
              </li>
        </ul>
      </div>
    `;
  });
})();