AO3: [Wrangling] Wrangling Page Info Box

Adds a customisable info box to the wrangling edit page

  1. // ==UserScript==
  2. // @name AO3: [Wrangling] Wrangling Page Info Box
  3. // @description Adds a customisable info box to the wrangling edit page
  4. // @author Ebonwing
  5. // @namespace http://tampermonkey.net/
  6. // @license GPL-3.0 <https://www.gnu.org/licenses/gpl.html>
  7. // @match *://*.archiveofourown.org/tags/*/edit
  8. // @grant none
  9. // @version 0.0.1.20211105173749
  10. // ==/UserScript==
  11.  
  12.  
  13. var settings = {};
  14.  
  15. /*********************
  16. *
  17. *
  18. * Customise the tags you want infoboxes on and the infobox text here.
  19. *
  20. *
  21. **********************/
  22.  
  23. //Replace the settings with tags and infotexts of your choosing. Copy and paste each new setting on a new line if you want more.
  24. //Inserting <br> makes a line break.
  25. //The tags in the brackets are not case sensitive.
  26.  
  27. //If you want an infobox on all tags containing a specific keyword, do this.
  28. settings["example"] = "This setting inserts this text into all urls that include the word example.";
  29.  
  30. //If you want to use a key term that has a space in it, replace the space(s) with %20
  31. settings["Dean%20Winchester"] = "This appears on any tag that contains 'Dean Winchester'.";
  32.  
  33. //For key terms with slashes, use *s*
  34. settings["Dean*s*Sam"] = "This appears on any tag that contains 'Dean/Sam'.";
  35.  
  36. //If you want a box only on specific tags, paste the entire link into the brackets.
  37. settings["https://archiveofourown.org/tags/ExampleTag/edit"] = "This tag appears only on the tag with that specific link.";
  38.  
  39.  
  40. //Example use cases:
  41. settings["edging"] = "Edging does not syn to edgeplay but to orgasm delay/denial.<br>";
  42. settings["aro"] = "Aroace tags aren't synned to ace tags.<br>";
  43.  
  44.  
  45.  
  46. var default_text = "This is a default text that appears on all noncanonical tags.";
  47. //If you don't want this to be shown on tags that have specific infoboxes, change the true value underneath this line to false.
  48. var always_show_default_text = true;
  49.  
  50.  
  51. /*********************
  52. *
  53. *
  54. * Customise the style of your infobox here.
  55. *
  56. *
  57. **********************/
  58.  
  59. //default style: cyan background, black border. Change the hex code after background: to customise it.
  60. var style = "background:#d1fcf6; border:1px solid black; padding:10px;";
  61.  
  62. //style that mimics AO3's default design, so it will appear as a plain sentence.
  63. //var style = "background:#dddddd;";
  64.  
  65. //Reversi compatible style:
  66. //var style = "background:#000;";
  67.  
  68.  
  69. /*********************
  70. *
  71. *
  72. * End of the customisation section
  73. *
  74. *
  75. **********************/
  76.  
  77.  
  78. var text = "";
  79. for (const [key, value] of Object.entries(settings)) {
  80. var url = window.location.href.toLowerCase();
  81. var tag = url.split("tags/")[1].split("/")[0];
  82. if(url == key){
  83. text = text + value;
  84. } else if(tag.includes(key)){
  85. text = text + value;
  86. }
  87. }
  88.  
  89.  
  90. if(!document.getElementById("tag_canonical").checked && always_show_default_text){
  91. text = text + default_text;
  92. }
  93.  
  94. if(text != ""){
  95. const div = document.createElement('div');
  96. div.id = "cheat_sheet";
  97. if (typeof style === 'undefined') {
  98. var style = "background:#d1fcf6; border:1px solid black; padding:10px;";
  99. }
  100. div.style = style;
  101. div.innerHTML = text;
  102.  
  103. var main = document.getElementById("main");
  104. var content = main.getElementsByTagName('dl');
  105. //content[0].parentNode.insertBefore(div, content[0]);
  106.  
  107. //checks if tag is in a fandom, since that changes the node placement
  108. if(content[0].childNodes.length == 21){
  109. content[0].childNodes[15].childNodes[3].parentNode.replaceChild(div, content[0].childNodes[15].childNodes[3]);
  110. } else if(content[0].childNodes.length == 25){
  111. content[0].childNodes[19].childNodes[3].parentNode.replaceChild(div, content[0].childNodes[19].childNodes[3]);
  112. }
  113.  
  114. }