Dynasty Thingifier

Adds post links and quote stuff to Dynasty forums

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