Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Display views & uploader
- // @author nonamethanks
- // @namespace display-views-uploader
- // @description Display views and original uploader in the post page
- // @version 1.0
- // @include *://*.donmai.us/posts/*
- // ==/UserScript==
- function starter(element, method) {
- if (typeof window[method] === "undefined") {
- window[method] = setInterval(function() {
- if ($(element).length) {
- method();
- clearInterval(window[method])
- }
- }, 100);
- }
- }
- function postViews() {
- async function _postViews() {
- const post_id = $("meta[name='post-id']").attr("content")
- $.get(
- `https://isshiki.donmai.us/post_views/${post_id}`,
- function(data) {
- $(`<li>Views: ${data}</li>`).insertAfter("#post-information > ul > li:nth-child(6)");
- }
- );
- }
- starter("#post-information", _postViews);
- }
- function displayUploader() {
- async function _displayUploader() {
- let uploader_id = $("#image-container").attr("data-uploader-id");
- let uploader_href = "/users/" + uploader_id;
- $.getJSON(
- "https://danbooru.donmai.us" + uploader_href + ".json",
- function (data) {
- let uploader = data["name"];
- let uploader_level = data["level_string"].toLowerCase();
- let li_element = $("<li>Uploader: </li>");
- let a_element = $(`<a class="user-post-uploader with-style">${uploader}</a>`);
- li_element.append(a_element);
- a_element.attr("href", uploader_href);
- a_element.addClass("user-" + uploader_level);
- li_element.insertAfter("#post-information > ul > li:nth-child(2)");
- }
- );
- }
- starter("#post-information", _displayUploader);
- }
- postViews();
- displayUploader();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement