SHARE
TWEET

Untitled

a guest Sep 20th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name     Make new post
  3. // @version  1
  4. // @include /.[cID]/
  5. // @exclude /^http://www.zikelverkstaden.tk:8888\/$/
  6. // @require https://raw.githack.com/a97marbr/ContextFreeLib/master/js/randapp.js
  7. // @require https://raw.githack.com/a97marbr/ContextFreeLib/master/js/contextfreegrammar.js
  8. // @grant    none
  9. // ==/UserScript==
  10.  
  11. let el2;
  12. let el3;
  13. let el4;
  14. let el5;
  15.  
  16. let sentences = [];
  17.  
  18. let entryName = "";
  19.  
  20. let uSlug = "";
  21.  
  22. let sDescription = "";
  23.  
  24. let contentText = "";
  25.  
  26. let sentenceCounter = 40;
  27.  
  28. let sentenceOffset;
  29.  
  30. window.onload = function() {
  31.   setTimeout(function(){
  32.     el2 = document.getElementById("ptComposer[7][name]");    
  33.     el3 = document.getElementById("ptComposer[8][url_slug]");
  34.     el4 = document.getElementById("ptComposer[9][description]");    
  35.     el5 = document.getElementsByClassName("cke_wysiwyg_div");
  36.    
  37.         createEntryName();
  38.    
  39.     console.log("all done!");
  40.   }, 2000);
  41. }
  42.  
  43. function createEntryName() {
  44.         var sentence="";
  45.         var grammar=new ContextFreeGrammar({
  46.                "probabilityNounPhrase":0.5,
  47.                "probabilityVerbPhrase":0.5,
  48.                "probabilityDualAdjectives":0.5,
  49.                "probabilityStartAdjective":0.5,
  50.                "distributionOfNouns":"normal",
  51.                "distributionOfVerbs":"normal",
  52.                "distributionOfAdjectives":"normal",
  53.                "distributionOfAdverbs":"normal",
  54.                "distributionOfDeterminers":"normal",
  55.                "distributionOfConjunctions":"normal",
  56.                "distributionOfModals":"normal",
  57.                "randomSeed":777
  58.              });
  59.  
  60.   for(var i=0;i<sentenceCounter;i++){
  61.     sentences.push(grammar.generateSentence());
  62.  }
  63.   for(var x = 0; x < sentences.length + 2 - sentences.length; x++){
  64.     entryName += sentences[x];
  65.     console.log(sentences[x]);
  66.     sentenceOffset += 2;
  67.   }
  68.   el2.value = entryName;
  69.  
  70.   uSlug = entryName.replace(/\s/g, "-");
  71.   uSlug = uSlug.replace(/\./g, "-");
  72.  
  73.   el3.value = uSlug;
  74.  
  75.   for(var z = 2; z < 6; z++) {
  76.     sDescription += sentences[z];
  77.     console.log(sentences[z]);
  78.   }
  79.   console.log(sDescription);
  80.   el4.value = sDescription;
  81.  
  82.   for(var c = 8; c < 21; c++) {
  83.      contentText += sentences[c];
  84.   }
  85.   console.log(contentText);
  86.   let editor = cke_1_contents
  87.   editor.setData(contentText);
  88.  
  89.   grammar.clearSeeds();
  90. }
  91.  
  92. /*
  93. CKEDITOR.instances["cke-7b21711e9329129e35177a2ae6e8ec66"].setData("hej");
  94. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top