Skip to content

Instantly share code, notes, and snippets.

@danieloskarsson
Last active September 24, 2018 21:30
Show Gist options
  • Save danieloskarsson/d60a905c1f731fc63316cd61697ed4e3 to your computer and use it in GitHub Desktop.
Save danieloskarsson/d60a905c1f731fc63316cd61697ed4e3 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name ContextFreeGhost
// @version 1
// @updateURL https://gist.githubusercontent.com/danieloskarsson/d60a905c1f731fc63316cd61697ed4e3/raw/
// @require https://rawgit.com/danieloskarsson/ContextFreeLib/master/js/contextfreegrammar.js
// @match http://localhost:2368/ghost*
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
// https://api.ghost.org/docs/user-authentication
var bearer = "shM5CBOHQoRAYeNxq7Gs79VhlurMuRTabMUIBMWlolEcieblZTgkmp3iAqnq5QvHPNZd1zlaAXwSdYgkwedTfp7KX0j1o14SvJI0WjcKEVLgjHpeD8buoLAjsCWzDZNc7rQrCZhf38ZRwJLnt5dmeuMBGHhEehOJKfLelXIsCpYS4DgSY0Ef3ZJEmFImXd8";
var seed = GM_getValue('seed') == null ? 1 : GM_getValue('seed') + 1
GM_setValue("seed", seed);
var contextFreeGrammar = new ContextFreeGrammar({
"probabilityNounPhrase":0.5,
"probabilityVerbPhrase":0.5,
"probabilityDualAdjectives":0.5,
"probabilityStartAdjective":0.5,
"distributionOfNouns":"uni-squared",
"distributionOfVerbs":"uni-squared",
"distributionOfAdjectives":"uni-squared",
"distributionOfAdverbs":"uni-squared",
"distributionOfDeterminers":"uni-squared",
"distributionOfConjunctions":"uni-squared",
"distributionOfModals":"uni-squared",
"randomSeed":seed
});
var title = seed + ": " + contextFreeGrammar.generateText(1);
var text = contextFreeGrammar.generateText(60);
GM_xmlhttpRequest ({
method: "POST",
url: "api/v0.1/posts/",
data: '{"posts":[{"custom_excerpt":null,"featured":false,"feature_image":null,"codeinjection_foot":"","codeinjection_head":"","custom_template":null,"og_image":null,"og_title":null,"og_description":null,"twitter_image":null,"twitter_title":null,"twitter_description":null,"locale":null,"meta_description":null,"meta_title":null,"mobiledoc":"{\\"version\\":\\"0.3.1\\",\\"atoms\\":[],\\"cards\\":[],\\"markups\\":[],\\"sections\\":[[1,\\"p\\",[[0,[],0,\\"' + text + '\\"]]]]}","page":false,"published_at":null,"slug":"","status":"published","title":"' + title +'","authors":[{"id":"1","name":"author","slug":"author","email":"[email protected]","profile_image":null,"cover_image":null,"bio":null,"website":null,"location":null,"accessibility":"{\\"nightShift\\":false}","status":"active","locale":null,"meta_title":null,"meta_description":null,"last_seen":null,"created_at":null,"updated_at":null,"facebook":null,"twitter":null,"tour":"[\\"getting-started\\",\\"using-the-editor\\",\\"upload-a-theme\\"]","roles":[]}],"createdBy":null,"publishedBy":null,"tags":[]}]}',
headers: {
"Authorization": "Bearer " + bearer,
"Content-Type": "application/json; charset=UTF-8"
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment