Last active
April 18, 2023 00:22
-
-
Save psenough/a9be72741d73ec2686c111a3490b01ee to your computer and use it in GitHub Desktop.
Demozoo pouet groups addon
This file contains 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 Demozoo pouet groups addon | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://demozoo.org/pouet/groups/* | |
// @match https://demozoo.org/productions/new/?* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=demozoo.org | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var res = document.getElementsByClassName("pouet_prod"); | |
for (var i = 0; i < res.length; i++) { | |
var value = res[i].value; | |
res[i].parentNode.innerHTML += ' <a target="_blank" href="https://demozoo.org/productions/new/?pouetid='+value+'">(insert)</a>'; | |
} | |
if (res.length === 0) { // should mean we are on new production page and not pouet/groups | |
const queryString = window.location.search; | |
const urlParams = new URLSearchParams(queryString); | |
const pouetid = urlParams.get('pouetid'); | |
$.ajax({ | |
url:"https://api.pouet.net/v1/prod/?id="+pouetid, | |
dataType: 'jsonp', // Notice! JSONP <-- P (lowercase) | |
success:function(json){ | |
// do stuff with json (in this case an array) | |
fillOutForm(json); | |
}, | |
error:function(){ | |
alert("Error"); | |
} | |
}); | |
} | |
function fillOutForm(myArr) { | |
var title = document.getElementById("id_title"); | |
title.value = myArr["prod"]["name"]; | |
var by = document.getElementById("id_byline_search"); | |
by.value = myArr["prod"]["groups"][0]["name"]; | |
var date = document.getElementById("id_release_date"); | |
var str = myArr["prod"]["releaseDate"]; | |
date.value = str.substring(0, str.length-3); | |
var url = document.getElementById("id_links-0-url"); | |
url.value = myArr["prod"]["download"]; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment