Created
March 22, 2021 12:02
-
-
Save NO-ob/8cf7517188a47342daf01074c7a96276 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Pixiv Bookmark redirect | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Makes pixiv redirect to image page after editing bookmark | |
// @author NO_ob | |
// @match https://www.pixiv.net/bookmark_add.php* | |
// @grant none | |
// @run-at document-idle | |
// ==/UserScript== | |
(function() { | |
let editButton = document.createElement("button"); | |
editButton.setAttribute("class","_button-large"); | |
editButton.setAttribute("id","scriptEditButton"); | |
editButton.setAttribute("type","button"); | |
editButton.innerHTML = "Edit Bookmark"; | |
document.querySelector("div.submit-container > input").remove(); | |
document.querySelector("div.submit-container").appendChild(editButton); | |
document.getElementById("scriptEditButton").addEventListener("click", submitForm); | |
})(); | |
function submitForm(){ | |
let xhr = new XMLHttpRequest(); | |
xhr.open("POST", document.querySelector("section._unit > form").action); | |
var formData = new FormData(document.querySelector("section._unit > form")); | |
xhr.onload = function(event){ | |
window.location = document.querySelector("div.thumbnail-container > a.work").href; | |
}; | |
// or onerror, onabort | |
xhr.send(formData); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment