Sleazy Fork is available in English.

nijienhance

nijie ajax bookmark 412305

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         nijienhance
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  nijie ajax bookmark 412305
// @author       nijietan
// @match        https://nijie.info/*
// @match        https://sp.nijie.info/*
// @icon         https://www.google.com/s2/favicons?domain=nijie.info
// @grant        none
// @license      MIT
// ==/UserScript==

;(function () {
  "use strict"
  console.log("running nijienhance")
  // sp のブックマークを fetch にする
  document
    .querySelectorAll('#bookmark_button > a[href^="bookmark_add.php"]')
    .forEach((elem) => {
      elem.removeAttribute("onclick")
      const handleBookmarkButton = (e) => {
        e.preventDefault()
        if (!confirm("[ajax] ブックマークに追加してもよろしいですか?")) return

        fetch(elem.href, {
          headers: {
            "cache-control": "no-cache",
          },
          referrer: location.href,
          referrerPolicy: "same-origin",
          method: "GET",
          credentials: "include",
        }).then((r) => {
          if (r.ok) {
            elem.href = elem.href.replace("add", "edit")
            elem.removeEventListener("click", handleBookmarkButton)
            const bookmark = elem.querySelector("#bookmark")
            if (bookmark) {
              bookmark.id = "bookmark_edit"
            }
          } else {
            alert("ブックマークの追加に失敗しました")
          }
        })
      }
      elem.addEventListener("click", handleBookmarkButton)
      console.log("applied", elem)
    })
  // pc のブックマークを fetch にする
  document.querySelectorAll('a[href^="/bookmark.php"]').forEach((elem) => {
    const url = new URL(elem.href)
    const _id = url.searchParams.get("id")
    if (!_id) return

    const handleBookmarkButton = (e) => {
      e.preventDefault()
      const bukumafolder = prompt("ブクマフォルダーを指定")
      if (bukumafolder === null) return
      fetch("https://nijie.info/bookmark_add.php", {
        headers: {
          "cache-control": "max-age=0",
          "content-type": "application/x-www-form-urlencoded",
        },
        referrer: location.href,
        referrerPolicy: "same-origin",
        body: `tag=${bukumafolder}&id=${_id}`,
        method: "POST",
        credentials: "include",
      }).then((r) => {
        if (r.ok) {
          elem.id = "bukuma"
          elem.href = elem.href.replace("add", "edit")
          elem.removeEventListener("click", handleBookmarkButton)
        } else {
          alert("ブックマークの追加に失敗しました")
        }
      })
    }
    elem.addEventListener("click", handleBookmarkButton)
    console.log("applied", elem)
  })
})()