Dynasty Thingifier

Adds post links and quote stuff to Dynasty forums

As of 26/01/2016. See the latest version.

  1. // ==UserScript==
  2. // @name Dynasty Thingifier
  3. // @namespace Alice Cheshire
  4. // @include http://dynasty-scans.com/*
  5. // @exclude http://dynasty-scans.com/system/images_images/*
  6. // @version 2.1.1.0
  7. // @require http://code.jquery.com/jquery-2.1.4.min.js
  8. // @description Adds post links and quote stuff to Dynasty forums
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @grant GM_deleteValue
  12. // @grant GM_listValues
  13. // @run-at document-end
  14. // ==/UserScript==
  15. (function() {
  16. "use strict";
  17. var pageurl = document.location.toString().replace(/(#.+)/, ""), //Stores page url and removes any anchors from the stored url so we don't get issues with multiple anchors showing up
  18. isuserpostsurl = document.location.toString(), //Stores the address variable a second time for use in a different function
  19. postids = [], //Initializes a blank array for the postids
  20. quote = [], //Initializes blank array for quotes
  21. postcount = 0, //Counter to keep track of how many posts are on the current page
  22. counter = 0,
  23. configmenustate = GM_getValue("configmenustate", true), //Init our menu state's varaiable
  24. yourid = GM_getValue("youruserid"), //Set our user id variable
  25. fontsize = [3, "one", "two", "three", "four", "five"],
  26. bbcode_menu = `
  27. <div id="thingifier-bbcode">
  28. <div class="thingifier-bbcode-first-row"><input type="button" id="thingifier-bbcode-quote" value="Quote">
  29. <input type="button" id="thingifier-bbcode-link" value="Link">
  30. <input type="button" id="thingifier-bbcode-image" value="Image">
  31. <input type="button" id="thingifier-bbcode-spoiler" value="Spoiler">
  32. <input type="button" id="thingifier-bbcode-ul" value="List">
  33. <input type="button" id="thingifier-bbcode-ol" value="Numbered List">
  34. <input type="button" id="thingifier-bbcode-italics" value="Italics">
  35. <input type="button" id="thingifier-bbcode-bold" value="Bold">
  36. </div>
  37. <div class="thingifier-bbcode-second-row">
  38. <input type="button" id="thingifier-bbcode-tag" value="Tags">
  39. <input type="button" id="thingifier-bbcode-hr" value="Horizontal Rule">
  40. <input type="button" id="thingifier-bbcode-codeblock" value="Code Block">
  41. <input type="button" id="thingifier-bbcode-h1" value="H1">
  42. <input type="button" id="thingifier-bbcode-h2" value="H2">
  43. <input type="button" id="thingifier-bbcode-h3" value="H3">
  44. <input type="button" id="thingifier-bbcode-h4" value="H4">
  45. <input type="button" id="thingifier-bbcode-h5" value="H5">
  46. <input type="button" id="thingifier-bbcode-h6" value="H6">
  47. </div>
  48. </div>`, //The html code for our bbcode buttons
  49. quickreply;
  50.  
  51. init();
  52.  
  53. //Initialize Script
  54. function init() {
  55. //Load our config
  56. configload();
  57.  
  58. //Populate Menu
  59. $('body').append(`
  60. <style>
  61. #thingifier {
  62. float: left;
  63. z-index: 1000 !important;
  64. max-width: 340px;
  65. max-height: 255px !important;
  66. }
  67. #thingifier, #magnifier-settings, #magnifier-submenu-toggle {
  68. top: 25%;
  69. position: fixed;
  70. }
  71. #thingifier-options {
  72. border: 1px solid black;
  73. padding: 8px;
  74. background: aliceblue;
  75. border-bottom-right-radius: 6px;
  76. border-left-width: 0;
  77. }
  78. #thingifier-options ul { list-style-type: none; margin-left: -4px;}
  79. #thingifier-options ul > li { vertical-align: middle; }
  80. #thingifier ul li input { padding-right: 4px; }
  81. #thingifier-font-size { width: 96px; }
  82. #thingifier-toggle-button {
  83. position: absolute;
  84. top: 0;
  85. left: calc(100% - 1px);
  86. width: 24px;
  87. height: 24px;
  88. border: 1px solid black;
  89. background-color: aliceblue;
  90. color: red;
  91. border-top-right-radius: 6px;
  92. border-bottom-right-radius: 6px;
  93. border-left-width: 0;
  94. }
  95. .spoilers-disabled {
  96. background: #666 none repeat scroll 0% 0%;
  97. color: #fff;
  98. }
  99. .navbar-fixed {
  100. position: fixed;
  101. z-index: 1000;
  102. width: 1210px;
  103. }
  104. .pull-right-fixed, .nav-collapse-fixed {
  105. float: right;
  106. }
  107. .nav-padding {
  108. height: 60px;
  109. width: 1210px;
  110. }
  111. .forum_post_one {
  112. font-size: 10px !important;
  113. line-height: 12px !important;
  114. }
  115. .forum_post_two {
  116. font-size: 12px !important;
  117. line-height: 15px !important;
  118. }
  119. .forum_post_three {
  120. font-size: 16px !important;
  121. line-height: 19px !important;
  122. }
  123. .forum_post_four {
  124. font-size: 20px !important;
  125. line-height: 23px !important;
  126. }
  127. .forum_post_five {
  128. font-size: 25px !important;
  129. line-height: 28px !important;
  130. }
  131. #thingifier-bbcode {
  132. margin-bottom: 6px;
  133. }
  134. #thingifier-quickreply {
  135. width: 100% !important;
  136. background-color: aliceblue !important;
  137. display: inline-block;
  138. padding: 4px;
  139. padding-bottom: 8px;
  140. border-radius: 8px;
  141. margin-bottom: 6px;
  142. }
  143. #magnifier {
  144. visibility: hidden;
  145. position: absolute;
  146. border: 1px solid grey;
  147. background-color: rgba(0, 0, 0, 0.1);
  148. background-repeat: no-repeat;
  149. pointer-events: none;
  150. z-index: 100000000;
  151. }
  152. #thingifier-magnifier-menu, #magnifier-tooltip {
  153. display: inline-block;
  154. border: 1px solid black;
  155. padding: 8px;
  156. background: aliceblue;
  157. border-radius: 6px;
  158. margin-left: 0px;
  159. vertical-align: top;
  160. }
  161. #thingifier-magnifier-menu input {
  162. display: inline-block;
  163. }
  164. #sizenum, #minsizenum {
  165. width: 96px;
  166. }
  167. #sizemeasure, #minsizemeasure {
  168. margin-left: 8px;
  169. }
  170. #sizemeasure, #minsizemeasure, #zoomfactor {
  171. width: 64px;
  172. }
  173. #minsizenum, #minsizemeasure, #zoomfactor, #squareborder, #circularborder {
  174. margin-top: 7px;
  175. }
  176. #magnifier-menu-submit {
  177. margin-left: 178px;
  178. margin-right: 8px;
  179. }
  180. #magnifier-buttons {
  181. margin-top: -24px;
  182. float: right;
  183. }
  184. #thingifier-magnifier-menu h3, #magnifier-tooltip h3 {
  185. text-align: center;
  186. text-decoration: underline;
  187. padding-bottom: 8px;
  188. }
  189. #thingifier-magnifier-menu h3 i {
  190. padding-bottom: 4px;
  191. border-bottom: 2px solid black;
  192. }
  193. #thingifier-magnifier-menu input {
  194. padding: 2px;
  195. margin: 2px;
  196. }
  197. #thingifier-magnifier-menu input[type="radio"], #thingifier-magnifier-menu label {
  198. display: inline;
  199. }
  200. #magnifier-tooltip h3 {
  201. padding-bottom: 10px;
  202. border-bottom: 1px solid black;
  203. }
  204. #magnifier-tooltip ul {
  205. padding: 0px;
  206. margin: 0px 10px;
  207. }
  208. #magnifier-tooltip li {
  209. margin: 0 8px;
  210. list-style: none;
  211. margin-bottom: 8px;
  212. line-height: 16px;
  213. font-size: 13px;
  214. }
  215. #magnifier-tooltip li {
  216. border-bottom: 1px solid black;
  217. padding-bottom: 8px;
  218. }
  219. #magnifier-tooltip li:last-of-type {
  220. border-bottom: 0px solid black;
  221. }
  222. #magnifier-tooltip li div {
  223. font-weight: 900;
  224. text-align: center;
  225. margin-bottom: -16px;
  226. margin-top: 8px;
  227. }
  228. #magnifier-tooltip li div::before, #magnifier-tooltip li div::after {
  229. content: " — ";
  230. }
  231. #thingifier-magnifier-menu {
  232. position: fixed;
  233. margin-left: 300px;
  234. border-radius: 6px 0 0 6px;
  235. margin-top: -108px !important;
  236. z-index: 1003 !important;
  237. width: 276px;
  238. border-right-width: 0;
  239. }
  240. #magnifier-tooltip {
  241. min-width: 320px;
  242. margin-left: 592px;
  243. z-index: 1000;
  244. top: 2% !important;
  245. position: fixed;
  246. max-width: 550px;
  247. }
  248. #magnifier-tooltip, #thingifier-magnifier-menu {
  249. margin-top: 148px;
  250. }
  251. #magnifier-settings, #magnifier-submenu-toggle {
  252. display: inline;
  253. z-index: 1001;
  254. }
  255. .thingifier-icon {
  256. background-image: url(http://dynasty-scans.com//assets/twitter/bootstrap/glyphicons-halflings-2851b489e8c39f8fad44fc10efb99c3e.png);
  257. display: inline-block;
  258. width: 14px;
  259. height: 14px;
  260. line-height: 14px;
  261. vertical-align: text-top;
  262. background-repeat: no-repeat;
  263. margin-top: 1px;
  264. background-position: -48px 0px;
  265. z-index: 1005 !important;
  266. }
  267. #magnifier-submenu-toggle {
  268. margin-left: 272px;
  269. margin-top: 132px;
  270. }
  271. #magnifier-submenu-toggle::after {
  272. margin-left: 18px;
  273. font-size: 12px;
  274. font-style: normal;
  275. content: "Settings";
  276. }
  277. #magnifier-submenu-toggle:hover {
  278. text-decoration: underline;
  279. cursor: pointer;
  280. }
  281. #thingifier-magnifier-menu input[type="number"], #thingifier-magnifier-menu input[type="text"] {
  282. text-align: center;
  283. }
  284. #magnifier-settings {
  285. pointer-events: none;
  286. }
  287. #magnifier-settings * {
  288. pointer-events: auto;
  289. }
  290. #thingifier-cancel {
  291. background-color: rgba(0,0,0,0.2) !important;
  292. background-image: linear-gradient(to bottom, rgb(196, 0, 0), rgb(96, 0, 0));
  293. color: white;
  294. margin-left: 4px;
  295. background-position: 0 !important;
  296. }
  297. #thingifier-cancel:hover {
  298. background-image: linear-gradient(to bottom, rgb(224, 0, 0), rgb(124, 0, 0));
  299. }
  300. input.btn {
  301. cursor: pointer !important;
  302. }
  303. </style>
  304. <div id="thingifier">
  305. <div id="thingifier-options">
  306. <ul>
  307. <li><input type="checkbox" id="thingifier-unhide-spoilers"> Unhide spoilers</li>
  308. <li><input type="checkbox" id="thingifier-fixed-navbar"> Fixed navbar</li>
  309. <li><input type="checkbox" id="thingifier-pagination"> Add page selector to top of page</li>
  310. <li><input type="checkbox" id="thingifier-bbcode-buttons"> Add quick reply and post page bbcode buttons</li>
  311. <li><input type="checkbox" id="thingifier-quote-to-quickreply"> Quote to quick reply instead of new post page</li>
  312. <li><input type="checkbox" id="thingifier-quote-move-quickreply"> Move quick reply to under quoted post</li>
  313. <li><input type="checkbox" id="thingifier-magnifier" tooltip="Press Z or middle mouse click"> Magnifier on reader and image pages</li>
  314. <li><input type="range" id="thingifier-font-size" min="1" max="5"> Change font size <input type="button" id="thingifier-reset-font" value="Reset Font Size"></li>
  315. <li><a href="http://dynasty-scans.com/forum/posts?user_id=${yourid}" id="thingifier-ownposts"> Your posts</a></li>
  316. <li><input type="text" id="useridinput"><input type="button" value="Submit user id" id="useridsubmit"></li>
  317. <li><input type="button" id="thingifier-clear" value="Clear stored data"></li>
  318. </ul>
  319. </div>
  320. <div id="thingified-toggle"><input type="button" id="thingifier-toggle-button" value="X"></div>
  321. <i class="thingifier-icon" id="magnifier-submenu-toggle"></i>
  322. <div id="thingifier-magnifier-menu">
  323. <h3><i class="thingifier-icon"></i> Magnifier Settings</h3>
  324. Size: <input type="number" id="sizenum"><input type="text" list="measurements" id="sizemeasure" pattern="vh|vw|vmin|vmax|%|px"><br>
  325. Minimum Size: <input type="number" id="minsizenum"><input type="text" list="measurements" id="minsizemeasure" pattern="vh|vw|vmin|vmax|%|px"><br>
  326. Zoom factor: <input type="number" id="zoomfactor">%<br>
  327. Shape: <input type="radio" id="squareborder" val="square" name="magnifier-shape"><label for="square" id="forsquare">Square </label><input type="radio" id="circularborder" val="circle" name="magnifier-shape"><label for="circle" id="forcircle">Circle</label><br>
  328. <span id="magnifier-buttons"><input type="button" id="magnifier-menu-submit" value="Save"><input type="button" id="magnifier-menu-cancel" value="Cancel"></span>
  329. <datalist id="measurements">
  330. <option value="vh">
  331. <option value="vw">
  332. <option value="vmin">
  333. <option value="vmax">
  334. <option value="%">
  335. <option value="px">
  336. </datalist>
  337. </div>
  338. <div id="magnifier-tooltip">
  339. <h3>Valid Size Types</h3>
  340. <ul>
  341. <li><div>vh</div><br>This is the vertical size of what you can see on the web page. It's measured in a percentage. (1-100% of that size. Ie: 1vh or 100vh.)</li>
  342. <li><div>vw</div><br>This is the horizontal size of what you can see on the web page. It's measured in a percentage. (1-100% of that size. Ie: 1vw or 100vw.)</li>
  343. <li><div>vmin</div><br>This is the smallest (horizontal or vertical) size of what you can see on the web page. It's measured in a percentage. (1-100% of that size. Ie: 1vmin or 100vmin.) On a desktop pc this will generally be the same as vh if you're browsing using a maximized window.</li>
  344. <li><div>vmin</div><br>This is the largest (horizontal or vertical) size of what you can see on the web page. It's measured in a percentage. (1-100% of that size. Ie: 1vmax or 100vmax.) On a desktop pc this will generally be the same as vw if you're browsing using a maximized window.</li>
  345. <li><div>%</div><br>This is a percent of the container size. In this case the size of the page itself. Note: Most pages on Dynasty that the magnifier works on aren't perfectly square so this could result in an elongated shape.</li>
  346. <li><div>px</div><br>A straight pixel size. (Ie: 256px results in a static 256 pixels in size regardless of the size of the page.)</li>
  347. </ul>
  348. </div>
  349. </div>
  350.  
  351. `);
  352.  
  353. //Setup own posts link stuff
  354. $('#useridinput').hide();
  355. $('#useridsubmit').hide();
  356. if (GM_getValue("youruserid", "Not Set") == "Not Set") {
  357. $('#thingifier-ownposts').hide();
  358. $('#useridinput').show();
  359. $('#useridsubmit').show();
  360. setuserid();
  361. }
  362.  
  363. //Check we're viewing a thread
  364. if (pageurl.match(/forum\/topics/)) {
  365. $('.forum_post').each(function() {
  366. postids.push(this.id); //For each element of the class forum_post push the element's id to our postids array
  367. });
  368. $('.time').each(function(i, obj) {
  369. postcount++; //This is where we actually count how many posts are on the page
  370. });
  371.  
  372. //Retrieve your user id
  373. if (GM_getValue("youruserid", "Not set").match(/\d+/)) {
  374. yourid = "http://dynasty-scans.com/forum/posts?user_id=" + GM_getValue("youruserid");
  375. } else {
  376. yourid = "Your user id isn't set!";
  377. }
  378. }
  379. }
  380.  
  381. //Set user ID for own posts link
  382. function setuserid() {
  383. $('input#useridsubmit').click(function () {
  384. if($("input#useridinput").val().match(/^\d+$/)) {
  385. GM_setValue("youruserid", $('input#useridinput').val());
  386. $('#useridinput').hide();
  387. $('#useridsubmit').hide();
  388. $('#thingifier-ownposts').show();
  389. $('#thingifier-ownposts').attr('href', "http://dynasty-scans.com/forum/posts?user_id=" + GM_getValue("youruserid"));
  390. } else {
  391. GM_deleteValue("youruserid");
  392. $("input#useridinput").val();
  393. $('input#useridinput').val("Invalid user id!");
  394. }
  395. });
  396. }
  397.  
  398.  
  399. //Menu close/open
  400. $('input#thingifier-toggle-button').click(function() {
  401. menuclose("click");
  402. });
  403.  
  404. //Unhide spoilers option
  405. $('#thingifier-unhide-spoilers').click(function() {
  406. if ($('#thingifier-unhide-spoilers').is(":checked")) {
  407. $('.spoilers').addClass('spoilers-disabled');
  408. } else {
  409. $('.spoilers').removeClass('spoilers-disabled');
  410. }
  411. GM_setValue("spoilers", $('#thingifier-unhide-spoilers').is(":checked"));
  412. });
  413.  
  414. //Fixed navbar option
  415. $('#thingifier-fixed-navbar').click(function() {
  416. if ($('#thingifier-fixed-navbar').is(":checked")) {
  417. GM_setValue("navbar", $('#thingifier-fixed-navbar').is(":checked"));
  418. $('.navbar').addClass('navbar-fixed');
  419. $('div.forum_post').css("padding-top", 40);
  420. $("<div class=\"nav-padding\"></div>").insertAfter(".navbar");
  421. } else {
  422. GM_setValue("navbar", $('#thingifier-fixed-navbar').is(":checked"));
  423. $('.navbar').removeClass('navbar-fixed');
  424. $('div.forum_post').css("padding-top", 0);
  425. $('div.nav-padding').remove();
  426. }
  427. });
  428.  
  429. //Pagination option
  430. $('#thingifier-pagination').click(function() {
  431. if ($('#thingifier-pagination').is(":checked")) {
  432. GM_setValue("pagination", $('#thingifier-pagination').is(":checked"));
  433. $("div.pagination").wrap('<div class=\"tmp\">').parent().html();
  434. var tmp = $('div.tmp').html();
  435. $("div.pagination").unwrap();
  436. $('#main').prepend(tmp);
  437. } else {
  438. GM_setValue("pagination", $('#thingifier-pagination').is(":checked"));
  439. $("div.pagination").first().remove();
  440. }
  441. });
  442.  
  443. //Add bbcode buttons to post page and quick reply
  444. $('#thingifier-bbcode-buttons').click(function() {
  445. if ($('#thingifier-bbcode-buttons').is(":checked")) {
  446. GM_setValue("bbcode", $('#thingifier-bbcode-buttons').is(":checked"));
  447. $("#forum_post_message").parent().prepend(bbcode_menu);
  448. } else {
  449. GM_setValue("bbcode", $('#thingifier-bbcode-buttons').is(":checked"));
  450. $("div#thingifier-bbcode").remove();
  451. }
  452. });
  453.  
  454. //Move the quick reply box to the current post
  455. $('#thingifier-quote-move-quickreply').click(function() {
  456. GM_setValue('movequickreply', $('#thingifier-quote-move-quickreply').is(":checked"));
  457. quickreply = $('#thingifier-quote-move-quickreply').is(":checked");
  458. });
  459. $('#thingifier-magnifier').click(function() {
  460. GM_setValue('magnifier', $('#thingifier-magnifier').is(":checked"));
  461. if (pageurl.match(/chapters/) || pageurl.match(/images/) && GM_getValue("magnifier", false)) {
  462. $('body').append('<div id="magnifier"></div>');
  463. } else {
  464. $('#magnifier').remove();
  465. }
  466. });
  467.  
  468. //Font size slider
  469. $('#thingifier-font-size').on('input', function() {
  470. fontsize[0] = parseInt($(this).val());
  471. $('.message *').removeClass('forum_post_one');
  472. $('.message *').removeClass('forum_post_two');
  473. $('.message *').removeClass('forum_post_three');
  474. $('.message *').removeClass('forum_post_four');
  475. $('.message *').removeClass('forum_post_five');
  476. $('.message *').addClass('forum_post_' + fontsize[fontsize[0]]);
  477. GM_setValue('fontsize', fontsize[0]);
  478. });
  479.  
  480. //Reset font size
  481. $('#thingifier-reset-font').click(function() {
  482. $('.message *').removeClass('forum_post_one');
  483. $('.message *').removeClass('forum_post_two');
  484. $('.message *').removeClass('forum_post_three');
  485. $('.message *').removeClass('forum_post_four');
  486. $('.message *').removeClass('forum_post_five');
  487. $('#thingifier-font-size').val(3);
  488. GM_deleteValue('fontsize');
  489. });
  490.  
  491. //Clear saved data
  492. $('#thingifier-clear').click(function() {
  493. var x = window.confirm("Are you sure you want to clear your stored data?");
  494. if (x) {
  495. var keys = GM_listValues();
  496. for each (var key in keys) {
  497. GM_deleteValue(key);
  498. }
  499. //console.log(GM_listValues());
  500. document.location.reload(true)
  501. } else {
  502. console.log("Decided against it");
  503. }
  504. });
  505.  
  506. //Load our config
  507. function configload() {
  508. //Only run once the page is loaded
  509. $(document).ready(function() {
  510. //Deal with our current menu state
  511. menuclose("load");
  512.  
  513. //Check if spoilers are unhidden
  514. if (!!GM_getValue("spoilers", false)) {
  515. $('#thingifier-unhide-spoilers').click();
  516. }
  517.  
  518. //Check if the fixed navbar is enabled
  519. if (!!GM_getValue("navbar", false)) {
  520. $('#thingifier-fixed-navbar').click();
  521. }
  522.  
  523. //Check if pagination option is enabled
  524. if (!!GM_getValue("pagination", false)) {
  525. $('#thingifier-pagination').click();
  526. }
  527.  
  528. //Check if we've changed the font size and retrieve it
  529. fontsize[0] = GM_getValue('fontsize', null);
  530. if (fontsize[0] !== null) {
  531. $('#thingifier-font-size').val(fontsize[0]);
  532. $('.message *').addClass('forum_post_' + fontsize[fontsize[0]]);
  533. }
  534.  
  535. //Check if bbcode buttons are enabled
  536. if (!!GM_getValue('bbcode', null)) {
  537. $('#thingifier-bbcode-buttons').click();
  538. }
  539.  
  540. //Check if quote to quick reply option is enabled
  541. if (!!GM_getValue('quote2quickreply', null)) {
  542. $('#thingifier-quote-to-quickreply').click();
  543. }
  544.  
  545. //Check if the move quick reply box option is enabled
  546. if (!!GM_getValue('movequickreply', null)) {
  547. $('#thingifier-quote-move-quickreply').click();
  548. }
  549. //Check if the magnifier option is enabled
  550. if (!!GM_getValue('magnifier', null)) {
  551. $('#thingifier-magnifier').click();
  552. }
  553.  
  554. bbcode();
  555. });
  556. }
  557.  
  558. function menuclose(sender) {
  559. //Only runs when loading a page
  560. if (sender === "load") {
  561. configmenustate = GM_getValue("configmenustate", true); //Load our menu state
  562. if (!configmenustate) { //If it's true collapse the menu
  563. $("#thingifier-options").animate({width:'toggle', height:'toggle'},0);
  564. $("#magnifier-submenu-toggle").fadeToggle(0);
  565. }
  566. $("#thingifier-magnifier-menu").fadeToggle(0);
  567. $("#magnifier-tooltip").fadeToggle(0);
  568.  
  569. //Runs when clicking the button
  570. } else if (sender === "click") {
  571. configmenustate = !!configmenustate ? false : true; //XOR our menu state, can also use ^=
  572. $("#thingifier-options").animate({width:'toggle', height:'toggle'},350); //Toggle the menu
  573. GM_setValue("configmenustate", !!configmenustate); //Store the value
  574. if ($('#thingifier-magnifier-menu').is( ":visible" )) {
  575. $('#thingifier-magnifier-menu').fadeToggle(0);
  576. $('#magnifier-tooltip').fadeToggle(0);
  577. }
  578. if ($("#magnifier-submenu-toggle").is( ":visible" )) {
  579. $("#magnifier-submenu-toggle").fadeToggle(0);
  580. } else {
  581. $("#magnifier-submenu-toggle").fadeToggle(500);
  582. }
  583. }
  584.  
  585. //Controls the button's icon
  586. if (!configmenustate) {
  587. $('#thingifier-toggle-button').val('▶');
  588. } else {
  589. $('#thingifier-toggle-button').val('◀');
  590. }
  591. }
  592.  
  593. function bbcode() {
  594. var texttmp,
  595. sel,
  596. posttmp,
  597. regextmp,
  598. txtbegin,
  599. txtend;
  600. $('#forum_post_message').mousedown(function() {
  601. $('body').mouseup(function() {
  602. getSel();
  603. texttmp = sel;
  604. posttmp = $('#forum_post_message').val();
  605. regextmp = new RegExp("("+texttmp.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&")+")");
  606. posttmp = posttmp.replace(regextmp, "[BBCODE-HERE]");
  607. });
  608. });
  609. function getSel() // javascript
  610. {
  611. // obtain the object reference for the <textarea>
  612. var txtarea = document.getElementById("forum_post_message");
  613. // obtain the index of the first selected character
  614. var start = txtarea.selectionStart;
  615. // obtain the index of the last selected character
  616. var finish = txtarea.selectionEnd;
  617. // obtain the selected text
  618. sel = txtarea.value.substring(start, finish);
  619. txtbegin = txtarea.value.substring(0, start);
  620. txtend = txtarea.value.substring(finish);
  621. // do something with the selected content
  622. }
  623. $('#thingifier-bbcode-quote').click(function() {
  624. texttmp = texttmp.replace(/(^\S)/gm, "> $1");
  625. bbcode_format();
  626. });
  627. $('#thingifier-bbcode-link').click(function() {
  628. if (sel.length === 0) {
  629. texttmp = texttmp.replace(/(.*)/gm, "[]($1)");
  630. } else {
  631. texttmp = texttmp.replace(/(.+)/gm, "[]($1)");
  632. }
  633. bbcode_format();
  634. });
  635. $('#thingifier-bbcode-image').click(function() {
  636. if (sel.length === 0) {
  637. texttmp = texttmp.replace(/(.*)/gm, "![]($1)");
  638. } else {
  639. texttmp = texttmp.replace(/(.+)/gm, "![]($1)");
  640. }
  641. bbcode_format();
  642. });
  643. $('#thingifier-bbcode-spoiler').click(function() {
  644. if (sel.length === 0) {
  645. texttmp = texttmp.replace(/(.*)/gm, "==$1==");
  646. } else {
  647. texttmp = texttmp.replace(/(.+)/gm, "==$1==");
  648. }
  649. bbcode_format();
  650. });
  651. $('#thingifier-bbcode-hr').click(function() {
  652. texttmp = texttmp.replace(/(^\S)/gm, "\n***\n $1");
  653. bbcode_format();
  654. });
  655. $('#thingifier-bbcode-ul').click(function() {
  656. texttmp = texttmp.replace(/(^\S)/gm, " * $1");
  657. bbcode_format();
  658. });
  659. $('#thingifier-bbcode-ol').click(function() {
  660. texttmp = texttmp.replace(/(^\S)/gm, " 1. $1");
  661. bbcode_format();
  662. });
  663. $('#thingifier-bbcode-italics').click(function() {
  664. if (sel.length === 0) {
  665. texttmp = texttmp.replace(/(.*)/gm, "*$1*");
  666. } else {
  667. texttmp = texttmp.replace(/(.+)/gm, "*$1*");
  668. }
  669. bbcode_format();
  670. });
  671. $('#thingifier-bbcode-bold').click(function() {
  672. if (sel.length === 0) {
  673. texttmp = texttmp.replace(/(.*)/gm, "**$1**");
  674. } else {
  675. texttmp = texttmp.replace(/(.+)/gm, "**$1**");
  676. }
  677. bbcode_format();
  678. });
  679. $('#thingifier-bbcode-tag').click(function() {
  680. if (sel.length === 0) {
  681. texttmp = texttmp.replace(/(.*)/gm, "`$1`");
  682. } else {
  683. texttmp = texttmp.replace(/(.+)/gm, "`$1`");
  684. }
  685. bbcode_format();
  686. });
  687. $('#thingifier-bbcode-codeblock').click(function() {
  688. if (sel.length === 0) {
  689. texttmp = texttmp.replace(/(.*)/gm, " $1 ");
  690. } else {
  691. texttmp = texttmp.replace(/(.+)/gm, " $1 ");
  692. }
  693. bbcode_format();
  694. });
  695. $('#thingifier-bbcode-h1').click(function() {
  696. if (sel.length === 0) {
  697. texttmp = texttmp.replace(/(.*)/gm, "# $1 #");
  698. } else {
  699. texttmp = texttmp.replace(/(.+)/gm, "# $1 #");
  700. }
  701. bbcode_format();
  702. });
  703. $('#thingifier-bbcode-h2').click(function() {
  704. if (sel.length === 0) {
  705. texttmp = texttmp.replace(/(.*)/gm, "## $1 ##");
  706. } else {
  707. texttmp = texttmp.replace(/(.+)/gm, "## $1 ##");
  708. }
  709. bbcode_format();
  710. });
  711. $('#thingifier-bbcode-h3').click(function() {
  712. if (sel.length === 0) {
  713. texttmp = texttmp.replace(/(.*)/gm, "### $1 ###");
  714. } else {
  715. texttmp = texttmp.replace(/(.+)/gm, "### $1 ###");
  716. }
  717. bbcode_format();
  718. });
  719. $('#thingifier-bbcode-h4').click(function() {
  720. if (sel.length === 0) {
  721. texttmp = texttmp.replace(/(.*)/gm, "#### $1 ####");
  722. } else {
  723. texttmp = texttmp.replace(/(.+)/gm, "#### $1 ####");
  724. }
  725. bbcode_format();
  726. });
  727. $('#thingifier-bbcode-h5').click(function() {
  728. if (sel.length === 0) {
  729. texttmp = texttmp.replace(/(.*)/gm, "##### $1 #####");
  730. } else {
  731. texttmp = texttmp.replace(/(.+)/gm, "##### $1 #####");
  732. }
  733. bbcode_format();
  734. });
  735. $('#thingifier-bbcode-h6').click(function() {
  736. if (sel.length === 0) {
  737. texttmp = texttmp.replace(/(.*)/gm, "###### $1 ######");
  738. } else {
  739. texttmp = texttmp.replace(/(.+)/gm, "###### $1 ######");
  740. }
  741. bbcode_format();
  742. });
  743. function bbcode_format() {
  744. var tmp = txtbegin + texttmp.replace(/\[BBCODE-HERE\]/, tmp) + txtend;
  745. $('#forum_post_message').val(tmp);
  746. }
  747. }
  748. $(document).ready(function() {
  749. if (isuserpostsurl.match(/http:\/\/dynasty-scans.com\/forum\/posts\?user_id=\d+/)) {
  750. isuserpostsurl = isuserpostsurl.replace(/\d+/, ""); //Replaces the user id in the url
  751. }
  752. for (var i = 0; i < postcount; i++){
  753. counter = i;
  754. var id = postids[i].toString(); //Temporarily store the post id under the key of 'i' into a variable to use in our next bit
  755. if ($('#thingifier-quote-to-quickreply').is(":checked")) {
  756. GM_setValue('quote2quickreply', $('#thingifier-quote-to-quickreply').is(":checked"));
  757. var tmp = $('.forum_post .info .row .actions').find("span:first-child a");
  758. var tmphref = tmp.attr('href');
  759. var urltmp = document.location.toString();
  760. urltmp = urltmp.replace(/(http:\/\/dynasty-scans\.com\/forum\/topics\/)(\d+)(.+)/, "$2");
  761. $('.forum_post .info .row .actions:eq(' + counter + ')').prepend("<input type=\"button\" class=\"postquote\" id=\"" + tmphref + "\" value=\"Quick Quote\" name=\"post_" + counter + "\">");
  762. id = id.replace(/forum_post_/, "");
  763. }
  764. if(isuserpostsurl !== "http://dynasty-scans.com/forum/posts?user_id=") {
  765. //If we're not on the user posts page then we turn all post timestamps on a page into an anchor link
  766. //".time").eq(i).replaceWith("<div class=\"span5 time\"><a class=\"timelink\" href=\"" + pageurl + "#forum_post_" + id + "\">" + $(".time").eq(i).text() + "</a></div>");
  767. }
  768. counter++;
  769. }
  770. $('#thingifier-quote-to-quickreply').click(function() {
  771. GM_setValue('quote2quickreply', $('#thingifier-quote-to-quickreply').is(":checked"));
  772. });
  773. $('input.postquote').mouseup(function(e) {
  774. document.getElementById('forum_post_message').value = "";
  775. var postid = $($(this).parents()[3]).attr('id');
  776. var quoteid = postid; //Gets the id of the .forum_post parent
  777. quoteid = "#" + quoteid; //Adds a url anchor sign to the id
  778. quoteid = quoteid.toString(); //Converts it to a string to make sure it cooperates
  779. GM_setValue("quoteid", pageurl + quoteid);
  780. var quotename = $.trim($(quoteid).find(".user").text().replace(/Staff|Moderator|Uploader/, "")); //Retrieve the quoted user's name
  781. //For staff, mods, and uploaders find and remove their title, then trim the whitespace/newlines off the beginning and end
  782. GM_setValue("quotename", quotename);
  783. postid = postid.replace(/forum_post_/, "");
  784. var threadid = document.location.toString();
  785. threadid = threadid.replace(/(http:\/\/dynasty-scans\.com\/forum\/topics\/)(\d+)(\S+)/, "$2");
  786. var postpath = "http://dynasty-scans.com/forum/posts/new?quote_id=\"" + postid +"\"&topic_id=\"" + threadid + "\"";
  787. postpath = postpath.replace(/"/g, "");
  788. postid = postid.replace(/post_/, "");
  789. getpost(postpath, postid);
  790. if (quickreply) {
  791. var replybox;
  792. if ($("#thingifier-quickreply").length < 1) {
  793. $("#new_forum_post").wrap("<div id=\"thingifier-quickreply\"></div>");
  794. $('<input class="btn" id="thingifier-cancel" type="button" value="Cancel Post">').insertAfter("#new_forum_post input.btn:last");
  795. }
  796. if (!replybox) {
  797. replybox = $("#thingifier-quickreply").detach();
  798. replybox.appendTo(quoteid);
  799. replybox = null;
  800. }
  801. }
  802. if ($("#thingifier-quickreply").offset().top > window.pageYOffset + document.documentElement.clientHeight || $("#thingifier-quickreply").offset().top < window.pageYOffset) {
  803. $(document).scrollTop($("#thingifier-quickreply").offset().top - $('div.nav-padding').height());
  804. }
  805. });
  806. $(document).on("click", "input#thingifier-cancel", function(){
  807. console.log("Clicked");
  808. var replybox = $('#new_forum_post').detach();
  809. $("#thingifier-quickreply").remove();
  810. replybox.appendTo('div.row:last');
  811. $('#thingifier-cancel').remove();
  812. });
  813.  
  814. //Do this if we click the quote button
  815. $('a').mouseup(function(e) { //When we click a link run this code
  816. if ($(e.target).text() == "Quote") { //Make sure that the clicked link is the quote button
  817. var quoteid = $(e.target).parents(); //Gets all the parent elements of our link
  818. quoteid = quoteid[4]; //Selects the fourth parent which is the .forum_post parent of the link
  819. quoteid = $(quoteid).attr('id'); //Gets the id of the .forum_post parent
  820. quoteid = "#" + quoteid; //Adds a url anchor sign to the id
  821. quoteid = quoteid.toString(); //Converts it to a string to make sure it cooperates
  822. GM_setValue("quoteid", pageurl + quoteid);
  823. var quotename = $(quoteid).find(".user").text(); //Retrieve the quoted user's name
  824. quotename = quotename.replace(/Staff|Moderator|Uploader/, ""); //For staff, mods, and uploaders find and remove their title
  825. quotename = $.trim(quotename); //Trim the whitespace/newlines off the beginning and end
  826. GM_setValue("quotename", quotename);
  827. } else { /*This is where code would run if we were doing anything for clicking other links*/ }
  828. });
  829.  
  830. //Check that the current page is the new posts page
  831. if (pageurl.match(/posts\/new/)) {
  832. var post = GM_getValue("quoteid", false);
  833. var username = GM_getValue("quotename", false);
  834. if (!!post && !!username) {
  835. quote = "> [**" + username + "** posted:](" + post + ") \n> ";
  836. var message = "\n" + $('#forum_post_message').val();
  837. $('#forum_post_message').val(quote + message);
  838. }
  839. }
  840. //Reset our quoteid and quotename values if we preview our post.
  841. $('input[value="Preview Post"]').click(function(e) {
  842. GM_deleteValue("quoteid");
  843. GM_deleteValue("quotename");
  844. });
  845. //Reset our quoteid and quotename values if we create our post.
  846. $('input[value="Create Post"]').click(function(e) {
  847. GM_deleteValue("quoteid");
  848. GM_deleteValue("quotename");
  849. });
  850. //Insert "unread posts" button after thread link in manga viewer
  851. if (pageurl.match(/chapters/)) {
  852. var mangathread = '<a class="btn btn-mini" title="View latest unread post in thread"href="' + $('div.btn-toolbar div.btn-group:first-child a.btn:first-child').attr('href') + '/unread"><i class="icon-comment"></i>Unread</a>';
  853. $(mangathread).insertAfter('div.btn-toolbar div.btn-group:first-child a.btn:first-child');
  854. }
  855. //Insert last post link to read threads
  856. if (pageurl.match(/\/forum(?!\/topics)/)) {
  857. var elements = $('div.forum_topic').length;
  858. for (i = 0; i < elements; i++) {
  859. //Retrieve the last page link or the base thread link if the thread is only one page
  860. var linktype = $('div.forum_topic:eq(' + i + ') span.pages a:last').attr('href') || $('div.forum_topic:eq(' + i + ') a.subject').attr('href');
  861. //Create our last post link
  862. var link = '<a class="thingifier-lastlink" href="' + linktype + '#lastpost" style="margin-left:10px;"><i class="icon-comment"></i>Last Post</a>';
  863. //Check if thread has multiple pages. If so place link after pagination, otherwise place it right after the thread link
  864. if ($('div.forum_topic:eq(' + i + ')').find('span.pages').length !== 0) {
  865. $(link).insertAfter('div.forum_topic:eq(' + i + ') span.pages');
  866. } else {
  867. $(link).insertAfter('div.forum_topic:eq(' + i + ') a.subject');
  868. }
  869. }
  870. }
  871. //Check if we clicked the last post button on the forum view
  872. $('a.thingifier-lastlink').mouseup(function(e) {
  873. if (e.which === 1 || e.which === 2) {
  874. var threadnum = $(this).attr('href').match(/(\d+)/)[0]; //Retrieve the clicked thread's ID
  875. GM_setValue('lastlink_' + threadnum, true); //If we left or middle clicked it then set our lastlink value for that thread to true
  876. }
  877. });
  878.  
  879. //Check if we're viewing a topic
  880. if (pageurl.match(/\/forum\/topics/) && window.location.toString().match(/#lastpost/)) {
  881. window.location = `${pageurl}#${$('div.time a:last').parents()[3].id}`;
  882. }
  883. //Magnifier Function
  884. var magY, magX, magShown = 0, imgPath = "none", zoom = GM_getValue('magZoomFactor', '500'), zoomFactor = zoom / 100, pWidth = 0, pHeight = 0, pOffset = 0, magZ = false;
  885. var updater = window.setInterval(update, 100);
  886.  
  887. $(document).mousemove(function(e) {
  888. if (GM_getValue("magnifier", false)) {
  889. zoomFactor = zoom / 100;
  890. magY = e.pageY;
  891. magX = e.pageX;
  892. $('#magnifier').offset({ top: magY - ($('#magnifier').height() / 2), left: magX - ($('#magnifier').width() / 2) });
  893. var backLeft = ((-magX + pOffset.left) * zoomFactor) + 130;
  894. var backTop = ((-magY + pOffset.top) * zoomFactor) + 130;
  895. $('#magnifier').css("background-position", backLeft + "px " + backTop + "px");
  896. }
  897. });
  898. $(document).mousedown(function(e) {
  899. if (GM_getValue("magnifier", false)) {
  900. var tmp = $(e.target).parent()[0];
  901. if (tmp.className === "image" && pageurl.match(/images/)) {
  902. tmp = tmp.className;
  903. } else if (tmp.id === "image" && pageurl.match(/chapters/)) {
  904. tmp = tmp.id;
  905. } else {
  906. tmp = false;
  907. }
  908. tmp = !!tmp;
  909. if (e.which === 2 && tmp !== false) {
  910. e.preventDefault();
  911. }
  912. magnifier(tmp, e.which);
  913. }
  914. });
  915. $(document).keydown(function(e) {
  916. if (e.which == 90) {
  917. if (GM_getValue("magnifier", false) && pageurl.match(/chapters/) || pageurl.match(/images/)) {
  918. if (!$('#forum_post_message').is(":focus") && !$('input#q').is(":focus")) {
  919. e.preventDefault();
  920. magZ = true;
  921. } else {
  922. magZ = false;
  923. }
  924. if (magZ === true) {
  925. magnifier(magZ, 2);
  926. }
  927. }
  928. }
  929. });
  930.  
  931. function magnifier(check, which) {
  932. if (GM_getValue("magnifier", false)) {
  933. if (!!check) {
  934. magShown = magShown ? 0 : 1;
  935. }
  936. if (!!magShown && !!check && which === 2) {
  937. $('#magnifier').css("visibility", "visible");
  938. $('*').css("cursor", "none");
  939. $('#magnifier').css({
  940. 'min-width' : GM_getValue('magMinSizeRes', "256") + GM_getValue('magMinSizeMeasure', "px"),
  941. 'min-height' : GM_getValue('magMinSizeRes', "256") + GM_getValue('magMinSizeMeasure', "px"),
  942. 'width' : GM_getValue('magSizeRes', "25") + GM_getValue('magSizeMeasure', "25"),
  943. 'height' : GM_getValue('magSizeRes', "25") + GM_getValue('magSizeMeasure', "25"),
  944. 'border-radius' : GM_getValue('magBorder', "50%")
  945. });
  946. zoom = GM_getValue('magZoomFactor', "500");
  947. $('#magnifier').offset({ top: magY - ($('#magnifier').height() / 2), left: magX - ($('#magnifier').width() / 2) });
  948. } else {
  949. $('#magnifier').css("visibility", "hidden");
  950. $('*').css("cursor", "auto");
  951. $('a').css("cursor", "pointer");
  952. $('a *').css("cursor", "pointer");
  953. $('span.left').css("cursor", "pointer");
  954. $('span.right').css("cursor", "pointer");
  955. }
  956. }
  957. }
  958. function update() {
  959. if (GM_getValue("magnifier", false)) {
  960. pOffset = $('#image img').offset() || $('div.image img').offset();
  961. if (pageurl.match(/chapters/)) {
  962. pWidth = $('div#image.thumbnail img').width() || $('div#image').width();
  963. pHeight = $('div#image.thumbnail img').height() || $('div#image').height();
  964. imgPath = $('div#image.thumbnail img').attr('src') || $('div#image img').attr('src') || "none";
  965. } else if (pageurl.match(/images/)) {
  966. pWidth = $('div.image img').width();
  967. pHeight = $('div.image img').height();
  968. imgPath = $('div.image img').attr('src') || "none";
  969. }
  970. if (imgPath !== "none") {
  971. //imgPath = imgPath.replace(/<img src=\"(.+)\">/, '$1');
  972. $('#magnifier').css("background-image", "url(" + imgPath + ")");
  973. //Zoom works correctly but the offset is WAY off
  974. /*var img = new Image;
  975. img.src = imgPath;
  976. pWidth = img.width;
  977. pHeight = img.height;*/
  978. $('#magnifier').css("background-size", (pWidth * zoomFactor) + "px " + (pHeight * zoomFactor) + "px");
  979. }
  980. }
  981. }
  982.  
  983. $('i#magnifier-submenu-toggle').click(function() {
  984. $("#thingifier-magnifier-menu").fadeToggle(350);
  985. $("#magnifier-tooltip").fadeToggle(350);
  986. $('#sizenum').val(GM_getValue('magSizeRes', '25'));
  987. $('#sizemeasure').val(GM_getValue('magSizeMeasure', 'vmin'));
  988. $('#minsizenum').val(GM_getValue('magMinSizeRes', '256'));
  989. $('#minsizemeasure').val(GM_getValue('magMinSizeMeasure', 'px'));
  990. $('#zoomfactor').val(GM_getValue('magZoomFactor', '500'));
  991. if (GM_getValue('magBorder', '50%') === '50%') {
  992. $('#circularborder').click();
  993. } else {
  994. $('#squareborder').click();
  995. }
  996. });
  997. $('#forcircle').click(function() {
  998. $('#circularborder').click();
  999. });
  1000. $('#forsquare').click(function() {
  1001. $('#squareborder').click();
  1002. });
  1003. $('#magnifier-menu-submit').click(function() {
  1004. var ferror = "",
  1005. border,
  1006. sizemeasure,
  1007. minsizemeasure,
  1008. size,
  1009. minsize;
  1010. if ($('#circularborder').is(':checked')) {
  1011. border = "50%";
  1012. } else {
  1013. border = "0";
  1014. }
  1015. //Size number
  1016. if ($('#sizenum').val().toString().match(/\d/g) !== null) {
  1017. size = $('#sizenum').val();
  1018. } else {
  1019. ferror += "Please use a number for the size!\n";
  1020. }
  1021. //Size measurement type
  1022. if (measurecheck($('#sizemeasure').val())) {
  1023. sizemeasure = $('#sizemeasure').val();
  1024. } else {
  1025. ferror += "Please use a valid type for the size!\n";
  1026. }
  1027. //Minimum size number
  1028. if ($('#minsizenum').val().toString().match(/\d/g) !== null) {
  1029. minsize = $('#minsizenum').val();
  1030. } else {
  1031. ferror += "Please use a number for the minimum size!\n";
  1032. }
  1033. //Minimum size measurement type
  1034. if (measurecheck($('#minsizemeasure').val())) {
  1035. minsizemeasure = $('#minsizemeasure').val();
  1036. } else {
  1037. ferror += "Please use a valid type for the minimum size!\n";
  1038. }
  1039. //Zoom factor
  1040. if ($('#zoomfactor').val().toString().match(/\d/g) !== null) {
  1041. zoom = $('#zoomfactor').val();
  1042. } else {
  1043. ferror += "Please use a number for the zoomfactor!\n";
  1044. }
  1045. //Check for errors or save
  1046. if (ferror !== "") {
  1047. alert(ferror);
  1048. } else {
  1049. GM_setValue('magSizeRes', size);
  1050. GM_setValue('magSizeMeasure', sizemeasure);
  1051. GM_setValue('magMinSizeRes', minsize);
  1052. GM_setValue('magMinSizeMeasure', minsizemeasure);
  1053. GM_setValue('magZoomFactor', zoom);
  1054. GM_setValue('magBorder', border);
  1055. $('i#magnifier-submenu-toggle').click();
  1056. }
  1057. });
  1058. $('#magnifier-menu-cancel').click(function() {
  1059. $("#thingifier-magnifier-menu").fadeToggle(350);
  1060. $("#magnifier-tooltip").fadeToggle(350);
  1061. });
  1062. function measurecheck(measure) {
  1063. //Should work just as well as an if loop using the || operator
  1064. switch(measure) {
  1065. case "vh":
  1066. case "vw":
  1067. case "vmin":
  1068. case "vmax":
  1069. case "%":
  1070. case "px":
  1071. return true;
  1072. break;
  1073. default:
  1074. return false;
  1075. break;
  1076. }
  1077. }
  1078. });//$(document).ready() end
  1079. function getpost(postpath, postid) {
  1080. var message = "";
  1081. $.ajax({
  1082. type: "GET",
  1083. url: postpath,
  1084. dataType: "text",
  1085. timeout: 10000,
  1086. cache: false
  1087. })
  1088. .done(function(data) {
  1089. quote[postid] = htmlDecode($(data).find('#forum_post_message'));
  1090. $('#forum_post_message').val(quote[postid]);
  1091. var post = GM_getValue("quoteid");
  1092. var username = GM_getValue("quotename");
  1093. quote = "> [**" + username + "** posted:](" + post + ") \n> ";
  1094. message = htmlDecode(data.replace(/([\u0000-\uffff]+<textarea .+ id="forum_post_message".+>)([\u0000-\uffff]+)(<\/textarea>[\u0000-\uffff]+)/, "$2"));
  1095. $('#forum_post_message').val(quote + message);
  1096. })
  1097. .fail(function() {
  1098. console.log("error");
  1099. });
  1100. }
  1101. function htmlDecode(input){
  1102. var e = document.createElement('div');
  1103. e.innerHTML = input;
  1104. return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
  1105. }
  1106. })();