Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. // ==UserScript==
  2. // @name GroupEight#2
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description HIS
  6. // @author You
  7. // @match http://groupeight.tk:8888/install-master/backend/rainlab/blog/posts/*
  8. // @require https://raw.githack.com/a97marbr/ContextFreeLib/master/js/contextfreegrammar.js
  9. // @require https://raw.githack.com/a97marbr/ContextFreeLib/master/js/randapp.js
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. var seed = 15;
  14. var sentence = '';
  15. var slug = document.getElementById('Form-field-Post-slug');
  16. var grammar = new ContextFreeGrammar({
  17. "probabilityNounPhrase":0.5,
  18. "probabilityVerbPhrase":0.5,
  19. "probabilityDualAdjectives":0.5,
  20. "probabilityStartAdjective":0.5,
  21. "distributionOfNouns":"normal",
  22. "distributionOfVerbs":"normal",
  23. "distributionOfAdjectives":"normal",
  24. "distributionOfAdverbs":"normal",
  25. "distributionOfDeterminers":"normal",
  26. "distributionOfConjunctions":"normal",
  27. "distributionOfModals":"normal",
  28. "randomSeed":seed
  29. });
  30.  
  31. function run(){
  32. // Fill Post
  33. setTimeout(function(){
  34. getSentencesTitle();
  35. makeid(6);
  36. getSentencesText();
  37. }, 300);
  38.  
  39. // Save Post
  40. setTimeout(function(){
  41. document.querySelector('.oc-icon-check').click();
  42. }, 500);
  43.  
  44. // Close Tab
  45. setTimeout(function(){
  46. window.close();
  47. }, 800);
  48. }
  49.  
  50. // Create title for the blogpost
  51. function getSentencesTitle(){
  52. for(var i = 0;i < 1; i++)
  53. {
  54. sentence=grammar.generateSentence();
  55. document.getElementById('Form-field-Post-title').value+=sentence;
  56. }
  57. }
  58.  
  59. // Create sentences for the blogpost
  60. function getSentencesText(){
  61. for(var i = 0; i < 10; i++)
  62. {
  63. sentence+=grammar.generateSentence();
  64. }
  65. CKEDITOR.instances['Editor-formContent-textarea-content'].setData(sentence);
  66. }
  67.  
  68. // Create blogpost "id"
  69. function makeid(length) {
  70. var result = '';
  71. var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  72. var charactersLength = characters.length;
  73. for (var i = 0; i < length; i++) {
  74. result += characters.charAt(Math.floor(Math.random() * charactersLength));
  75. }
  76. slug.value = result;
  77. }
  78.  
  79. // Run the creation of a blogpost.
  80. run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement