LemmyTools

A small suite of tools to make Lemmy easier.

当前为 2023-06-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name LemmyTools
  3. // @namespace https://thesimplecorner.org/c/lemmytools
  4. // @version 0.1.2
  5. // @description A small suite of tools to make Lemmy easier.
  6. // @author howdy@thesimplecorner.org
  7. // @include https://*
  8. // @run-at document-end
  9. // ==/UserScript==
  10.  
  11. //todo:
  12. //
  13.  
  14.  
  15. const ltConfig = `
  16. // ------------ EDIT THIS VARIABLE ---------------------
  17. var homeInstance = 'https://thesimplecorner.org';
  18. // ------------ END EDIT AREA --------------------------
  19. // Fixes remote Instance home linl
  20.  
  21.  
  22. //Nothing below needs edited.
  23.  
  24.  
  25.  
  26. // -------------- VERSION -------------------
  27. const ltVer = '0.1.2';
  28. const ltTestedVer = '0.18';
  29. var comm = '';
  30.  
  31. //--------------------------------------------
  32. `;
  33.  
  34.  
  35. const funcs = `
  36.  
  37. function isltMobile(){
  38. if (/Android|iPhone/i.test(navigator.userAgent)) {
  39. console.log("LemmyTools: " + "is mobile!");
  40. return true;
  41. }
  42. else
  43. {
  44. console.log("LemmyTools: " + "is desktop!");
  45. return false;
  46. }
  47. }
  48.  
  49.  
  50. let remoteCommunityArray = [];
  51. function update(comm, page, subString, hI) {
  52.  
  53. var el = document.getElementById("myDiv");
  54. try{
  55. if (comm)
  56. {
  57.  
  58. var browsedComm = "<li><h5>" + comm + "</h5><a href=" + subString + " target='_blank'><button class='ltbutton'>Easy Subscribe</button></a></li>";
  59. remoteCommunityArray.push(browsedComm);
  60. }
  61. }
  62. catch{}
  63. return remoteCommunityArray;
  64.  
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
  71. function Toggle(overide) {
  72.  
  73. let settings = options();
  74. var s = document.getElementById("searchdiv");
  75. var size = s.getBoundingClientRect();
  76. var x = document.getElementById("myDiv");
  77. var b = document.getElementById("toggle");
  78. var h = document.getElementById("ltBarHeader");
  79. var cs = document.getElementById("commsearch");
  80.  
  81. //on remote instance just hide the bar.
  82. if (overide == 0)
  83. {
  84. console.log("LemmyTools: " + "overiding bar to hide.");
  85. x.style.display = "none";
  86. }
  87.  
  88. if (x.style.display === "none") {
  89. x.style.display = "block";
  90. s.style.height = "100%";
  91. cs.style.display = "inline";
  92. h.innerHTML = "<h6><a href=" + settings.theInstance + ">Home</a> - <a href='https://lemmyverse.net/communities' target='_new'>Find Comms</a> - <a href='#' id='LToptions' onclick='options(" + 1 + ")'>Options</a></h6>";
  93. s.style[settings.positionSide] = "0%";
  94.  
  95. }
  96. else {
  97. x.style.display = "none";
  98. s.style.height = "auto";
  99. h.innerHTML = '<img style="margin-' + settings.positionSide + ': 120px !Important; position:static;" class="targetImg" src="data:image/webp;base64,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" width="32" height="32" />';
  100. cs.style.display = "none";
  101.  
  102. if (size.width > 261){
  103. s.style[settings.positionSide] = "-7.33%";
  104. }
  105. else{
  106. s.style[settings.positionSide] = "-190px";
  107. }
  108. }
  109.  
  110. }
  111.  
  112.  
  113. function searchComms(id, full, commsdiv) {
  114. console.log("LemmyTools: " + "commsearch evt searchinput" + id + commsdiv);
  115. var url = window.location.href;
  116. var query = id.toLowerCase();
  117. if (query == "") {
  118. var commsCount = localStorage.getItem("commsCount");
  119. if ((commsCount == null) || (full.length < 1))
  120. {
  121. commsdiv.innerHTML = "<hr /><b>Welcome to LemmyTools! Ver " + ltVer + "</b><br /><br />If this is your first time running the script, set your lemmy homeinstance in the option page. [" + ltVer + "] - Manually enter your home lemmy instance in script for offsite home button functionality. (temporary)]. <br /><br /> If you dont see your subscribed communities here simply login to your lemmy and then click the LemmyTools home button above. ";
  122. }
  123. else
  124. {
  125. commsdiv.innerHTML = "Communities: " + commsCount + '<hr />';
  126. commsdiv.innerHTML += full;
  127. }
  128. }
  129. else {
  130. commsdiv.innerHTML = full;
  131. console.log("LemmyTools: " + "Searching for:" + query);
  132. var children = commsdiv.getElementsByTagName("li");
  133. console.log("LemmyTools: " + "Children found: " + children.length);
  134. let data = [""];
  135. var found;
  136. for (var i = 0; i < children.length; i++) {
  137. if (children[i].innerHTML.toLowerCase().indexOf(query) !== -1) {
  138. found = children[i].innerHTML + '<br /><hr />';
  139. console.log("LemmyTools: " + "Found: " + found);
  140. data.push(found);
  141. }
  142. }
  143. let dup = [...new Set(data)];
  144. data = dup;
  145. data.sort();
  146. commupdate(commsdiv, url, data);
  147. }
  148. }
  149.  
  150.  
  151. function commupdate(id, page, data) {
  152. console.log("LemmyTools: " + "Comm Update");
  153. var count = -1;
  154.  
  155. //console.log("LemmyTools: " + "updating " + id + " commsearch with: " + data);
  156. data.forEach(_ => count++);
  157. id.innerHTML = "";
  158. id.innerHTML += "Results: " + count + "<hr /><br />";
  159. id.innerHTML += data;
  160. }
  161.  
  162.  
  163.  
  164.  
  165. function options(open){
  166. var odiv = document.getElementById("ltOptions");
  167. console.log("LemmyTools: " + "Options Functions");
  168. if (open == 1)
  169. {
  170. odiv.style.display = "block";
  171.  
  172. }
  173. else if (open == 2){
  174. //First run set defaults or pull from localstorage.
  175.  
  176. mobile = isltMobile();
  177.  
  178. commposSide = localStorage.getItem("option_commposSide");
  179. reverseSide = localStorage.getItem("option_reverseSide");
  180. var instance = localStorage.getItem("option_homeInstance");
  181. commposVertical = localStorage.getItem("option_commposVertical");
  182. expandImages = localStorage.getItem("option_expandImages");
  183. expandImagesize = localStorage.getItem("option_expandImageSize");
  184. hoverCheck = localStorage.getItem("option_hoverCheck");
  185. hideSideBar = localStorage.getItem("option_hideSideBar");
  186. unblurNSFW = localStorage.getItem("option_unblurNSFW");
  187. alienSiteOld = localStorage.getItem("option_alienSiteOld");
  188. if (localStorage.getItem('option_commposSide') == null)
  189. {
  190. console.log("LemmyTools: First Run Defaults");
  191. commposSide = "right";
  192. reverseSide = "left";
  193. if (mobile)
  194. {
  195. commposSide = "left";
  196. reverseSide = "right";
  197. }
  198. else
  199. {
  200. commposSide = "right";
  201. reverseSide = "left";
  202. }
  203. }
  204. if (localStorage.getItem('option_homeInstance') == null)
  205. {
  206. if (homeInstance != '')
  207. {
  208. instance = homeInstance;
  209. }
  210. else
  211. {
  212. //alert('Welcome to LemmyTools. LemmyTools has defaulted to this lemmy instance.');
  213. //instance = window.location.origin;
  214. }
  215. }
  216. if (localStorage.getItem('option_commposVertical') == null)
  217. {
  218. if (mobile)
  219. {
  220. commposVertical = "5";
  221. }
  222. else
  223. {
  224. commposVertical = "5";
  225. }
  226. }
  227. if (localStorage.getItem('option_expandImages') == null)
  228. {
  229. expandImages = "true";
  230. }
  231. if (localStorage.getItem('option_hideSideBar') == null)
  232. {
  233. hideSideBar = "false";
  234. }
  235. if (localStorage.getItem('option_expandImageSize') == null)
  236. { if (mobile)
  237. {
  238. expandImagesize = "100";
  239. }
  240. else
  241. {
  242. expandImagesize = "50";
  243. }
  244.  
  245. }
  246. if (localStorage.getItem('option_hoverCheck') == null)
  247. {
  248. hoverCheck = "false";
  249. }
  250. if (localStorage.getItem('option_unblurNSFW') == null)
  251. {
  252. unblurNSFW = "false";
  253. }
  254. if (localStorage.getItem('option_alienSiteOld') == null)
  255. {
  256. if (mobile)
  257. {
  258. alienSiteOld = "false";
  259. }
  260. else
  261. {
  262. alienSiteOld = "true";
  263. }
  264. }
  265.  
  266. localStorage.setItem("option_commposSide", commposSide);
  267. localStorage.setItem("option_reverseSide", reverseSide);
  268. localStorage.setItem("option_homeInstance", instance);
  269. localStorage.setItem("option_commposVertical", commposVertical);
  270. localStorage.setItem("option_expandImages", expandImages);
  271. localStorage.setItem("option_expandImageSize", expandImagesize);
  272. localStorage.setItem("option_hideSideBar", hideSideBar);
  273. localStorage.setItem("option_hoverCheck", hoverCheck);
  274. localStorage.setItem("option_unblurNSFW", unblurNSFW);alienSiteOld
  275. localStorage.setItem("option_alienSiteOld", alienSiteOld);
  276. }
  277. else if (open == 3)
  278. {
  279. //save button
  280. odiv.style.display = "none";
  281.  
  282.  
  283.  
  284. var commposSide = document.getElementsByName("option_commposSide")[0];
  285. var value = commposSide.options[commposSide.selectedIndex].value;
  286. commposSide = value;
  287.  
  288. theHomeinstance = document.getElementsByName("option_homeInstance")[0];
  289. value = theHomeinstance.value;
  290. theHomeinstance = value;
  291.  
  292. var commposVertical = document.getElementsByName("option_commposVertical")[0];
  293. value = commposVertical.value;
  294. commposVertical = value;
  295.  
  296. var expandImages = document.getElementsByName("option_expandImages")[0];
  297. value = expandImages.checked;
  298. expandImages = value;
  299.  
  300. var expandImagesize = document.getElementsByName("option_expandImageSize")[0];
  301. value = expandImagesize.value;
  302. expandImagesize = value;
  303.  
  304. var hideSideBar = document.getElementsByName("option_hideSideBar")[0];
  305. value = hideSideBar.checked;
  306. hideSideBar = value;
  307.  
  308. var hoverCheck = document.getElementsByName("option_hoverCheck")[0];
  309. value = hoverCheck.checked;
  310. hoverCheck = value;
  311.  
  312. var unblurNSFW = document.getElementsByName("option_unblurNSFW")[0];
  313. value = unblurNSFW.checked;
  314. unblurNSFW = value;
  315.  
  316. var alienSiteOld = document.getElementsByName("option_alienSiteOld")[0];
  317. value = alienSiteOld.checked;
  318. alienSiteOld = value;
  319.  
  320. if (commposVertical > 85)
  321. {
  322. commposVertical = 85;
  323. }
  324. else if (commposVertical <= -1)
  325. {
  326. commposVertical = 0;
  327. }
  328.  
  329.  
  330. var reverseSide = "";
  331.  
  332. if (commposSide == "left")
  333. {
  334. reverseSide = "right";
  335. }
  336. else
  337. {
  338. reverseSide = "left";
  339. }
  340.  
  341. localStorage.setItem("option_commposSide", commposSide);
  342. localStorage.setItem("option_reverseSide", reverseSide);
  343. localStorage.setItem("option_homeInstance", theHomeinstance);
  344. localStorage.setItem("option_commposVertical", commposVertical);
  345. localStorage.setItem("option_hideSideBar", hideSideBar);
  346. localStorage.setItem("option_expandImages", expandImages);
  347. localStorage.setItem("option_expandImageSize", expandImagesize);
  348. localStorage.setItem("option_hoverCheck", hoverCheck);
  349. localStorage.setItem("option_unblurNSFW", unblurNSFW);
  350. localStorage.setItem("option_alienSiteOld", alienSiteOld);
  351. location.reload(true);
  352. }
  353.  
  354. commposSide = localStorage.getItem("option_commposSide");
  355. reverseSide = localStorage.getItem("option_reverseSide");
  356. instance = localStorage.getItem("option_homeInstance");
  357. commposVertical = localStorage.getItem("option_commposVertical");
  358. expandImages = localStorage.getItem("option_expandImages");
  359. expandImagesize = localStorage.getItem("option_expandImageSize");
  360. hideSideBar = localStorage.getItem("option_hideSideBar");
  361. hoverCheck = localStorage.getItem("option_hoverCheck");
  362. unblurNSFW = localStorage.getItem("option_unblurNSFW");
  363. alienSiteOld= localStorage.getItem("option_alienSiteOld");
  364.  
  365. const userOptions = {theInstance: instance, positionSide: commposSide, reverseSide: reverseSide, positionVertical: commposVertical,expandImages: expandImages, expandImagesize: expandImagesize, hideSideBar: hideSideBar, hoverCheck: hoverCheck, unblurNSFW: unblurNSFW, alienSiteOld: alienSiteOld};
  366. return userOptions;
  367.  
  368.  
  369. }
  370. function scrollToElement(pageElement) {
  371. var positionX = 0,
  372. positionY = -130;
  373.  
  374. while(pageElement != null){
  375. positionX += pageElement.offsetLeft;
  376. positionY += pageElement.offsetTop;
  377. pageElement = pageElement.offsetParent;
  378. window.scrollTo(positionX, positionY, "smooth");
  379. }
  380. }
  381. function removeClassByWildcard(divClass) {
  382. // If the class ends with a "*", then it matches all classes that start with the given class name.
  383. if (divClass.endsWith("*")) {
  384. divClass = divClass.replace('*', '');
  385. // Get all elements with the given class name.
  386. var elements = document.getElementsByTagName("div");
  387. var re = new RegExp("(^|\\s)" + divClass + "(\\s|$)");
  388. let result = [];
  389. let className = "";
  390. for (var i=0; i<elements.length; i++) {
  391. if (re.test(elements[i].className)) {
  392. console.log("Match: " + elements[i]);
  393. result.push(elements[i]);
  394. for (var y=0; y<elements[i].classList.length; y++)
  395. {
  396. if (elements[i].classList[y].indexOf(divClass) !== -1)
  397. {
  398. className = elements[i].classList[y];
  399. console.log(className);
  400. }
  401. }
  402. }
  403. }
  404. // Remove the class from all elements.
  405. for (var i = 0; i < result.length; i++) {
  406. result[i].classList.remove(className);
  407. }
  408. } else {
  409. // Otherwise, the class must match exactly.
  410. var elements = document.querySelectorAll("[class=" + divClass + "]");
  411.  
  412. // Remove the class from all elements.
  413. for (var i = 0; i < elements.length; i++) {
  414. elements[i].classList.remove(divClass);
  415. }
  416. }
  417.  
  418. }
  419. `;
  420.  
  421. /*--- */
  422.  
  423. const main = `
  424. // LemmyTools
  425. //check if first run or load saved settings
  426. let settings = options("2");
  427.  
  428. //settings.alienSiteOld = "true";
  429. if (settings.alienSiteOld == "true")
  430. {
  431. alienSiteOldStyle_compact();
  432. }
  433.  
  434.  
  435. /* Script */
  436. var url = window.location.href;
  437. var currentPage = url;
  438. var broken = url.split('/c/');
  439. var site = broken[0];
  440. site = site.replace('https://', '');
  441. var community = broken[1];
  442. var subString = settings.theInstance + "/search?q=!" + community + "@" + site + "&type=All&listingType=All&page=1";
  443. subString = subString.replace('#', '');
  444. var count = 0;
  445. if (isltMobile())
  446. {
  447. //Toggle(0);
  448. }
  449.  
  450.  
  451.  
  452. //Better Subscription List --------------------------
  453.  
  454.  
  455.  
  456. const mouseReference = {
  457. mouseMove: false,
  458. buttonDown: false,
  459. x: false,
  460. y: false
  461. }
  462.  
  463.  
  464.  
  465.  
  466. setInterval(function() {
  467.  
  468. document.onmousedown = e => {
  469.  
  470.  
  471.  
  472. if (settings.expandImages == "true")
  473. {
  474.  
  475. //Hide Existing Expanded images (stop pages from scrolling weird)
  476. if (e.srcElement.classList.contains('img-expanded'))
  477. {
  478.  
  479. var mouseX = document.clientX;
  480. var mouseY = document.clientY;
  481. try{
  482. var alreadySeen = document.getElementsByClassName('hasExpanded');
  483.  
  484. for (var i = 0; i < alreadySeen.length; i ++) {
  485. alreadySeen[i].style.display = 'none';
  486. }
  487.  
  488. } //end try
  489. catch {}
  490.  
  491. e.srcElement.closest("a").setAttribute('onclick', 'return false;');
  492. e.srcElement.closest("a").setAttribute('overflow', 'auto;');
  493. e.preventDefault();
  494. var img = e.srcElement
  495.  
  496. var imgwidth = img.width;
  497. var imgheight = img.height;
  498. ratio = imgheight / imgwidth;
  499.  
  500. mouseReference.buttonDown = true;
  501. img.style.cursor = "move";
  502. img.classList.remove('overflow-hidden');
  503. var initialX = img.offsetTop;
  504. var initialY = img.offsetLeft;
  505. document.addEventListener("dblclick", function(e) {
  506. mouseReference.buttonDown = false;
  507. window.location = img.src;
  508. });
  509.  
  510.  
  511. document.addEventListener("mousemove", function(e) {
  512. mouseMove = true;
  513.  
  514. document.addEventListener("mouseup", function(e) {
  515. e.preventDefault();
  516. mouseReference.buttonDown = false;
  517. clearTimeout(imgTimeout);
  518. });
  519.  
  520.  
  521. if(e.which === 1 && mouseReference.buttonDown && mouseMove) {
  522. scrollToElement(img);
  523. document.addEventListener("mouseup", function(e) {
  524. e.preventDefault();
  525. mouseReference.buttonDown = false;
  526. img.style.cursor = "auto";
  527. clearTimeout(imgTimeout);
  528. delete window.img;
  529. if (img.classList.contains('thumbnail') == false)
  530. {
  531. img.classList.add("hasExpanded");
  532. }
  533. }); //mouse up
  534.  
  535. e.preventDefault();
  536. mouseX = e.clientX;
  537. mouseY = e.clientY;
  538. var deltaY = mouseY;
  539. var deltaX = mouseX ;
  540.  
  541. deltaY = ((initialY / 2) + mouseY) * 1.1;
  542. imgTimeout = setTimeout(function() {
  543. img.style.height = deltaY + "px";
  544. img.style.width = img.height / ratio + "px";
  545. }, 10);
  546.  
  547. } // if e.which
  548. });
  549. }
  550. else if ((e.target.id == 'searchdiv') || (e.target.id == 'myDiv') || (e.target.classList.contains('card-header')) || (e.target.classList.contains('clickAble')) || (e.target.classList.contains('targetImg')) )
  551. {
  552. if (settings.hoverCheck !== "true")
  553. {
  554. Toggle();
  555. }
  556. }
  557. } // if expand images
  558. } // document body e
  559.  
  560. //Removes the offset from images.
  561. try{removeClassByWildcard("offset-*");}catch{}
  562.  
  563.  
  564. //sidebar settings do
  565. if (settings.hideSideBar == "true"){
  566. try{
  567. var sidebarSubscribed = document.getElementById("sidebarContainer");
  568. sidebarSubscribed.style.display = 'none';
  569. removeClassByWildcard("site-sideba*");
  570.  
  571. var serverInfo = document.getElementById("sidebarInfo");
  572. var serverInfoString = serverInfo.innerHtml;
  573. serverInfo.style.display = 'none';
  574. }
  575. catch {}
  576. }
  577.  
  578.  
  579. }, 100);
  580.  
  581.  
  582. //Option Divs
  583. if (settings.expandImages == "true")
  584. {
  585. eIcheck = 'checked';
  586. }
  587. else
  588. {
  589. eIcheck = '';
  590. }
  591. if (settings.hideSideBar == "true")
  592. {
  593. hSBcheck = 'checked';
  594. }
  595. else
  596. {
  597. hSBcheck = '';
  598. }
  599. if (settings.hoverCheck == "true")
  600. {
  601. hoverCheck = 'checked';
  602. }
  603. else
  604. {
  605. hoverCheck = '';
  606. }
  607. if (settings.unblurNSFW == "true")
  608. {
  609. unblurCheck = 'checked';
  610. }
  611. else
  612. {
  613. unblurCheck = '';
  614. }
  615. if (settings.alienSiteOld == "true")
  616. {
  617. aSOcheck = 'checked';
  618. }
  619. else
  620. {
  621. aSOcheck = '';
  622. }
  623.  
  624.  
  625.  
  626. var odiv = document.createElement("div");
  627. odiv.setAttribute("id", "ltOptions");
  628. odiv.classList.add("ltoptions", "border-secondary", "card");
  629. odiv.innerHTML = "<h4>LemmyTools " + ltVer + " Options</h4></hr>" +
  630. "<div class='table-responsive'><table class='table'>" +
  631. "<thead class='pointer'>" +
  632. "<tr><th>Option:</th>" +
  633. "<th>Value:</th>" +
  634. "</thead></tr>" +
  635. "<tbody>" +
  636. "<tr><td><b>LemmyTools Settings:</b></td><td></td></tr>" +
  637. "<tr><td><b>HomeInstance URL</b><br /> Make sure to edit the homeInstance variable of<br /> the UserScript for the remote instance Home button fix. (Temporary workaround).<br />(Ex: https://yourinstance.lemmy)</td><td><textarea name='option_homeInstance'>" + settings.theInstance + "</textarea></td></tr>" +
  638. "<tr><td><b>LemmyTools bar window side</b><br /> - default: right</td><td><select name='option_commposSide'><option value='" + settings.positionSide + "'>" + settings.positionSide + "</option><option value='right'>right</option><option value='left'>left</option></select></td></tr>" +
  639. "<tr><td><b>LemmyTools bar vertical position </b><br />% from top [0-85] - default: desktop-5, mobile-65</td><td><textarea name='option_commposVertical'>" + settings.positionVertical + "</textarea></td></tr>" +
  640. "<tr><td><b>Hover to activate LemmyTools bar</b><br />Otherwise click.</td><td><input type='checkbox' name='option_hoverCheck'" + hoverCheck + "/></td></tr>" +
  641. "<tr><td><br /><br /></td><td></td></tr>" +
  642. "<tr><td><b>Site Style and Behaviors:</b></td><td></td></tr>" +
  643. "<tr><td><b>Compact Lemmy to old.Reddit Re-format (Lemmy v0.18) style</b><br />Like the old alien.site but lemmy! <br />Defaults - Desktop: On / Mobile: Off</td><td><input type='checkbox' name='option_alienSiteOld'" + aSOcheck + "/></td></tr>" +
  644. "<tr><td><b>Hide Lemmy Sidebars</b><br /> (Trending, ServerInfo, Communities)<br /> More room for images on feed.</td><td><input type='checkbox' name='option_hideSideBar'" + hSBcheck + "/></td></tr>" +
  645. "<tr><td><b>Expandable Images</b><br />Acts as an auto-expander and adds the ability to manually<br /> expand images by clicking and dragging.<br />Doubleclick to open full image.</td><td><input type='checkbox' name='option_expandImages' " + eIcheck + "/></td></tr>" +
  646. "<tr><td><b>Auto Expand Size</b><br />Size of post image after opening a image post.<br /> Desktop Default: 50 / Mobile: 100</td><td><textarea name='option_expandImageSize'>" + settings.expandImagesize + "</textarea></td></tr>" +
  647. "<tr><td><b>Auto unblur NSFW images</b><br /></td><td><input type='checkbox' name='option_unblurNSFW'" + unblurCheck + "/></td></tr>" +
  648. "<tr><td></td><td><button id='LTsaveoptions' onclick='options(3)'>Save / Close</button></td></tr></tbody></table></div>" +
  649. "<p> Tested on Lemmy Version: " + ltTestedVer + " on firefox. " +
  650. "<br /><h5>LemmyTools Links</h5><hr /><a href='https://thesimplecorner.org/c/lemmytools'>!lemmytools@thesimplecorner.org</a><br />Get it here: <a href='https://github.com/howdy-tsc/LemmyTools'>Github</a> or <a href='https://greasyfork.org/en/scripts/469169-lemmytools'>GreasyFork</a>" +
  651. "<br />Please submit issues to the github for feature requests and problems: <a href='https://github.com/howdy-tsc/LemmyTools/issues'>Github LemmyTools Issues</a><br /></p>" +
  652. "<br /><a href='https://ko-fi.com/lemmytools'><img src='https://storage.ko-fi.com/cdn/nav-logo-stroke.png' width='32' /><br />Enjoy LemmyTools?<br />Tip with coffee!</a>" +
  653. "<br /><br /><b>Attributes/Credit: </b><br /><li>The provided style pack option of 'Compact Lemmy to old.Reddit Re-format (Lemmy v0.18)' was graciously used with permission from the developer(s). <br />Please support their project here:" +
  654. "<a href='https://github.com/soundjester/lemmy_monkey'> Compact Lemmy to old.Reddit Re-format (Lemmy v0.18)</a></li>";
  655.  
  656. document.body.appendChild(odiv);
  657.  
  658.  
  659. var height = window.innerHeight
  660. || document.documentElement.clientHeight
  661. || document.body.clientHeight;
  662. height = (height/100 * 1);
  663.  
  664. //Comm divs
  665. var touchdiv = document.createElement("div");
  666. touchdiv.setAttribute("id", "touchdiv");
  667. var idiv = document.createElement("div");
  668. idiv.setAttribute("id", "searchdiv");
  669. idiv.classList.add("ltmenu", "border-secondary", "card");
  670. idiv.innerHTML = "<span class='clickAble' style='float:" + settings.reverseSide + ";'> <header id='ltBarHeader' class='card-header'><h6><a href=" + settings.theInstance + ">Home</a> - <a href='https://lemmyverse.net/communities' target='_new'>Find Comms</a> - <a href='#' id='LToptions' onclick='options(" + 1 + ")'>Options</a></h6></header><input type='text' id='commsearch' name='commsearchinput' oninput='searchComms(commsearch.value, communityArray, div)' placeholder='Search your subscriptions (or visted subs)' /></span><b class='clickAble'>LemmyTools " + ltVer + "</b><div style='clear:both;'></div>";
  671. var div = document.createElement("div");
  672. div.setAttribute("id", "myDiv");
  673. div.classList.add("ltcommsbar");
  674.  
  675.  
  676. var styleString = ".ltmenu {position: fixed; top: " + settings.positionVertical +"%;" + settings.positionSide + ": 0; font-size: .75em; display: block; height: 100%; min-height: auto; z-index:999; overflow:scroll; border: thick double; border-right:none !important; outline: 1px solid grey !important;}" +
  677. ".ltmenu input { width: 100%;}" +
  678. ".ltcommsbar { word-wrap: break-word; overflow:auto; height:100%; width:240px;}" +
  679. ".ltcommsbar hr {display:block;}" +
  680. ".ltbutton {background-color: #ccffe5;}" +
  681. ".img-fluid {width: " + settings.expandImagesize + "%}" +
  682. "#searchdiv {position: fixed; height: 100%; min-height: auto; width: 240px; display:block; z-index:999; overflow: auto; display: block; transition-timing-function: ease; transition: " + settings.positionSide + " .25s; " + settings.positionSide + " : 0; transition-delay: 0, 1s; overflow: auto;}" +
  683. ".ltoptions {position: fixed; min-width: auto; min-height: auto; width: auto; height:100%; top:0;" + "display:none; left: 0; overflow:scroll; z-index:1000; padding:0.5%; border: thick double;}";
  684.  
  685. //Hover ltBar
  686. if (settings.hoverCheck == "true")
  687. {
  688. styleString += "#searchdiv:not(:hover) { transition-timing-function: ease; transition: " + settings.positionSide + ".25s; " + settings.positionSide + " : -215px;transition-delay: 1s, 2s;} ";
  689. }
  690. else
  691. {
  692. styleString += "#searchdiv:not(:hover) {}";
  693. }
  694. if (settings.unblurNSFW == "true")
  695. {
  696. styleString += " .img-blur {filter: none !important; -webkit-filter: none !important; -moz-filter: none !important; -o-filter: none !important; -ms-filter: none !important;} ";
  697. }
  698. else
  699. {
  700. styleString += " .img-blur {filter: blur !important; -webkit-filter: blur !important; -moz-filter: blur !important; -o-filter: blur !important; -ms-filter: blur !important;} ";
  701. }
  702.  
  703. if (settings.hideSideBar == "true")
  704. {
  705. styleString += ".container, .container-lg, .container-md, .container-sm, .container-xl { }" +
  706. ".col-md-8 {flex: 0 0 80% !important;max-width: 80%;}";
  707. }
  708. else
  709. {
  710. styleString += ".container, .container-lg, .container-md, .container-sm, .container-xl {}";
  711. }
  712.  
  713. // ADD MAIN CSS
  714. const addCSS = css => document.head.appendChild(document.createElement("style")).innerHTML = css;
  715. addCSS(styleString);
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722. url = location.href;
  723. console.log("LemmyTools: " + "url is " + url)
  724. // -----------------------------------------------
  725. //Add divs to page;
  726. document.body.appendChild(idiv);
  727. idiv.appendChild(div);
  728.  
  729. let rCommunityArray = [];
  730.  
  731. //Easier Subscribe Buttons ---------------------------
  732. //Browsing remote instance
  733. setInterval(function() {
  734. var url = window.location.href;
  735. var currentPage = url;
  736. var broken = url.split('/c/');
  737. var site = broken[0];
  738. site = site.replace('https://', '');
  739. var community = broken[1];
  740. var subString = settings.theInstance + "/search?q=!" + community + "@" + site + "&type=All&listingType=All&page=1";
  741. subString = subString.replace('#', '');
  742.  
  743.  
  744. url = window.location.href;
  745. if (currentPage != location.href) {
  746. console.log("LemmyTools: " + "Easy Sub Running...");
  747. if (document.querySelector('meta[name="Description"]').content.includes("Lemmy")) {
  748. console.log("LemmyTools: " + "On remote lemmy");
  749. if ((url.includes(settings.theInstance) == false) && ((url.includes("/c/") || url.includes("/post/") || url.includes("/comment/") || url.includes("/communities")))) {
  750. console.log("LemmyTools: " + "On remote instance community" + "Button to: " + subString);
  751. rCommunityArray = update(community, url, subString, settings.theInstance);
  752. let rDup = [...new Set(rCommunityArray)];
  753. rCommunityArray = rCommunityArray.reverse();
  754. div.innerHTML = '';
  755. div.innerHTML += rCommunityArray;
  756. communityArray = rCommunityArray;
  757. }
  758. }
  759. }else if (document.querySelector('meta[name="Description"]').content.includes("Lemmy")) {
  760. console.log("LemmyTools: " + "On lemmy");
  761. if ((url.includes(settings.theInstance) == false) && ((url.includes("/c/") || url.includes("/post/") || url.includes("/comment/") || url.includes("/communities")))) {
  762. console.log("LemmyTools: " + "On remote instance community - DIRECT -" + "Button to: " + subString);
  763. rCommunityArray = update(community, url, subString, settings.theInstance);
  764. let rDup = [...new Set(rCommunityArray)];
  765. rCommunityArray = rDup;
  766. rCommunityArray = rCommunityArray.reverse();
  767. div.innerHTML = '';
  768. div.innerHTML += rCommunityArray;
  769. communityArray = rCommunityArray;
  770. }
  771. }
  772.  
  773.  
  774.  
  775. currentPage = location.href;
  776. }, 1000);
  777.  
  778. //Logged in
  779. // -----------------------------------------------
  780. let communityArray = new Array();
  781. if (url.includes(settings.theInstance)) {
  782. console.log("LemmyTools: " + "home instance do bar");
  783. document.querySelectorAll('[class="list-inline-item d-inline-block"]').forEach(function(el) {
  784. communityArray.push("<li>" + el.innerHTML + "</li>");
  785. });
  786. let dup = [...new Set(communityArray)];
  787. communityArray = dup;
  788. if ((count == 0) || (count == null)) {
  789. count = 0;
  790. communityArray.forEach(_ => count++);
  791. }
  792. div.innerHTML += communityArray;
  793. if (div.innerHTML.length >= 20) {
  794. console.log("LemmyTools: Got Results >20");
  795. console.log("LemmyTools: " + "setting localcomms localstore");
  796. localStorage.setItem("localComms", communityArray);
  797. localStorage.setItem("commsCount", count);
  798. //force update the page
  799. searchComms("", communityArray, div);
  800. } else {
  801. console.log("LemmyTools: " + "get localcomms from localstore");
  802. communityArray = localStorage.getItem("localComms");
  803. div.innerHTML += communityArray;
  804. //force update the page
  805. searchComms("", communityArray, div);
  806. }
  807.  
  808.  
  809. }
  810. else {
  811. console.log("LemmyTools: On Remote Instance - Bar");
  812. //div.innerHTML = localStorage.getItem("remoteComms");
  813. //Toggle(0);
  814.  
  815. }
  816.  
  817.  
  818.  
  819.  
  820. `;
  821.  
  822. /* The provided restyling was graciously used with permission from the developer(s) of Compact Lemmy to old.Reddit Re-format (Lemmy v0.18)
  823.  
  824. // @name Compact Lemmy to old.Reddit Re-format (Lemmy v0.18)
  825. // @namespace https://github.com/soundjester/lemmy_monkey
  826. // @description Reformat widescreen desktop to look more like Reddit
  827. // @version 2.4
  828. // @author mershed_perderders, DarkwingDuck, dx1@lemmy.world, Djones4822, Jakylla
  829.  
  830. Thank you.
  831. */
  832.  
  833. const alienSiteOldStyle = ` ${
  834. function alienSiteOldStyle_compact(){
  835. 'use strict';
  836. /***********************************/
  837. /* set desired thumbnail size here */
  838. /* 70px - compact default */
  839. /* 100px - large thumbnail default */
  840. /***********************************/
  841. var thumbnailSize = 70;
  842. var readingWidth = 940; /*controls the width of comments and text posts on individual post pages - default=940*/
  843. /***********************************/
  844.  
  845. function AppendCommentCountText(container) {
  846. var svgElem = container.querySelectorAll("svg")[0].outerHTML;
  847. var numComms = container.title;
  848. var spanElem = container.querySelectorAll("span");
  849. var spanElemHTML = "";
  850. if(spanElem[0]){
  851. spanElemHTML = " " + spanElem[0].outerHTML
  852. }
  853. container.innerHTML = svgElem + numComms + spanElemHTML;
  854. }
  855.  
  856. function ApplyCommentCountText(element) {
  857. const observer = new MutationObserver(function(mutationsList) {
  858. for (let mutation of mutationsList) {
  859. if (mutation.type === 'childList') {
  860. for (let addedNode of mutation.addedNodes) {
  861. try {
  862. var comm_count = addedNode.querySelectorAll(".btn.btn-link.btn-sm.text-muted.ps-0");
  863. comm_count.forEach(AppendCommentCountText);
  864. } catch (_er) {
  865. console.log(_er);
  866. return;
  867. }
  868. }
  869. }
  870. }
  871. });
  872.  
  873. observer.observe(element, { childList: true, subtree: true });
  874. }
  875.  
  876. function AppendPostURL(container) {
  877. var tld_link = container.querySelectorAll(".d-flex.text-muted.align-items-center.gap-1.small.m-0")[0];
  878. var post_details = container.querySelectorAll("span.small")[0];
  879. if (tld_link) {
  880. var post_detail = tld_link.nextSibling.innerText;
  881. post_details.innerHTML += " • " + tld_link.innerHTML
  882. }
  883. }
  884.  
  885. function ApplyAppendPostURL(element) {
  886. const observer = new MutationObserver(function(mutationsList) {
  887. for (let mutation of mutationsList) {
  888. if (mutation.type === 'childList') {
  889. for (let addedNode of mutation.addedNodes) {
  890. try {
  891. var comm_count = addedNode.querySelectorAll("article > .col-12.col-sm-9 > .row > .col-12");
  892. comm_count.forEach(AppendPostURL);
  893. } catch (_er) {
  894. console.log(_er);
  895. return;
  896. }
  897. }
  898. }
  899. }
  900. });
  901.  
  902. observer.observe(element, { childList: true, subtree: true });
  903. }
  904. const css = `
  905. /**************************/
  906. /* NSFW automatic un-blur */
  907. /**************************/
  908. .img-blur {
  909. filter: none !important;
  910. -webkit-filter: none !important;
  911. -moz-filter: none !important;
  912. -o-filter: none !important;
  913. -ms-filter: none !important;
  914. }
  915. /***************************/
  916. /* bootstrap column widths */
  917. /***************************/
  918. /*main container*/
  919. .container, .container-lg, .container-md, .container-sm, .container-xl {
  920. max-width: 100% !important;
  921. }
  922. .home {
  923. padding-left: 1em !important;
  924. }
  925. /*sidebar width*/
  926. .col-md-4 {
  927. flex: 0 0 20% !important;
  928. max-width: 20%;
  929. padding-right: unset !important;
  930. }
  931. /*main post area (witdh optimized for widescreen)*/
  932. .col-md-8 {
  933. flex: 0 0 80% !important;
  934. max-width: 80%;
  935. }
  936. .col-sm-2 {
  937. flex: 0 0 10% !important;
  938. max-width: 10%;
  939. }
  940. .col-sm-9 {
  941. flex: 0 0 80% !important;
  942. max-width: 80%;
  943. }
  944. .col-8 {
  945. max-width: 100% !important;
  946. }
  947. /* specific column combos that need padding adjustment*/
  948. /* .col-12.col-md-8 {
  949. padding-left: unset !important;
  950. }
  951. */
  952. /* .col-12.col-sm-9 {
  953. padding-left: unset !important;
  954. }
  955. */
  956. /* navbar padding*/
  957. .navbar {
  958. /*padding-left: 0 !important;
  959. */
  960. padding-right: 1em !important;
  961. }
  962. .navbar-nav {
  963. margin-top: 0px !important;
  964. margin-bottom: 0px !important;
  965. }
  966. /* control vertical padding*/
  967. .mb-1, .my-1 {
  968. margin-bottom: 0.1rem !important;
  969. }
  970. .mb-2, .my-2 {
  971. margin-bottom: 0.1rem !important;
  972. }
  973. .mt-3, .my-3 {
  974. margin-top: 0.1rem !important;
  975. }
  976. .mt-4, .my-4 {
  977. margin-top: 0.1rem !important;
  978. }
  979. /***************/
  980. /* voting area */
  981. /***************/
  982. /*can be modified as you like*/
  983. .vote-bar {
  984. font-size: 0.85em !important;
  985. flex: 0 0 4% !important;
  986. max-width: 4% !important;
  987. margin-top:unset !important;
  988. }
  989. /******************/
  990. /* thumbnail area */
  991. /******************/
  992. /*keep thumbnails as square as we can and about the size of each post row*/
  993. .post-media {
  994. min-width: +thumbnailSize+px !important;
  995. max-width: +thumbnailSize+px !important;
  996. margin-right: 1em !important;
  997. }
  998. .thumbnail {
  999. min-height: +thumbnailSize+px !important;
  1000. max-height: +thumbnailSize+px !important;
  1001. min-width: +thumbnailSize+px !important;
  1002. max-width: +thumbnailSize+px !important;
  1003. background-color: #333;
  1004. object-fit: scale-down; /* instead of "cover" */
  1005. }
  1006. /*this is needed for videos/gifs*/
  1007. .embed-responsive {
  1008. min-height: +thumbnailSize+px !important;
  1009. max-height: +thumbnailSize+px !important;
  1010. min-width: +thumbnailSize+px !important;
  1011. max-width: +thumbnailSize+px !important;
  1012. }
  1013. /*apply specific styling to text posts*/
  1014. .post-media a[href^="/post/"] .thumbnail {
  1015. border: 1px solid #333;
  1016. background-color: unset !important;
  1017. }
  1018. /*******************/
  1019. /* main page posts */
  1020. /*******************/
  1021. /* post title font size*/
  1022. .h5, h5 {
  1023. font-size: 1rem !important;
  1024. margin-bottom: 0.1rem !important;
  1025. }
  1026. .small, small {
  1027. font-size: 80%;
  1028. font-weight: 400;
  1029. }
  1030. /*can be adjusted smaller, but beyond .25 is gets too tight and individual post spacing starts to appear overlapping*/
  1031. .post-listing {
  1032. margin: 0.25rem 0 !important;
  1033. padding: 0.25rem 0 !important;
  1034. }
  1035. .post-listing picture img.rounded-circle {
  1036. width: 1.25rem;
  1037. height: 1.25rem;
  1038. }
  1039. /*hide link TLD until it is moved back to the old spot*/
  1040. p.d-flex.text-muted.align-items-center.gap-1.small.m-0 {
  1041. display: none !important;
  1042. }
  1043. /*thumbnail width control (keep it square, dang it!)*/
  1044. .post-listing .d-none .row .col-sm-2 {
  1045. max-width: 100px;
  1046. }
  1047. .post-listing .d-none .row .col-sm-9 {
  1048. display: flex;
  1049. align-items: unset !important;
  1050. }
  1051. /*comment number and fediverse/lemmy links*/
  1052. .ps-0 {
  1053. font-size: 0.75rem !important;
  1054. }
  1055. /*the below .btn is deprecated as .py-0 (above) provides more consistent spacing;
  1056. however, some may prefer the look of smaller text on buttons*/
  1057. /*.btn {
  1058. font-size:0.75rem !important;
  1059. }
  1060. */
  1061. /*media collapse/expand button - appears after post title for offsite links that have a thumbnail*/
  1062. .btn.btn-sm.text-monospace.text-muted.d-inline-block {
  1063. padding-top: 0;
  1064. padding-bottom: 0;
  1065. }
  1066. .text-body.mt-2.d-block{
  1067. font-size: 0.8rem;
  1068. display: none !important;
  1069. }
  1070. /************/
  1071. /* comments */
  1072. /************/
  1073. /* restrict post and comment width - adjust to preference */
  1074. /* may use li[role="comment"] instead of .md-div - this fully restricts all comment elements (eg. divider lines_ */
  1075. #postContent, .md-div, .alert-warning {
  1076. max-width: +readingWidth+px;
  1077. }
  1078. .mb-3.row {
  1079. max-width: +(readingWidth+25)+px; /*top-comment textarea needs extra width*/
  1080. }
  1081. /*top comment doesn't need to hug the comment sort buttons.*/
  1082. .comments:first-child {
  1083. margin-top: 0.5rem !important;
  1084. }
  1085. /*allow top-level comment box to be resized*/
  1086. div > textarea {
  1087. resize: both !important;
  1088. }
  1089. /*increase the indent for child comments*/
  1090. .ms-1 {
  1091. margin-left: 1em !important;
  1092. }
  1093. /***********/
  1094. /* sidebar */
  1095. /***********/
  1096. #sidebarContainer {
  1097. padding-right: 1em;
  1098. }
  1099. /******************************/
  1100. /* entire page display tweaks */
  1101. /******************************/
  1102. #app > div > .container-lg {
  1103. margin-left: 1em !important;
  1104. max-width: 99% !important;
  1105. margin-left: unset !important;
  1106. }
  1107. #app > nav > .container-lg {
  1108. max-width: 100% !important;
  1109. }
  1110. #app > navbar > .container-lg {
  1111. margin-left: unset !important;
  1112. }
  1113. /* post index layout*/
  1114. #app > .mt-4 > .container-lg hr.my-3 {
  1115. display: none;
  1116. }
  1117. #app > .mt-4 > .container-lg > .row {
  1118. margin: unset !important;
  1119. }
  1120. /* post layout*/
  1121. #app > .mt-4 > .container-lg > .row > main {
  1122. max-width: 100%;
  1123. }
  1124. #app > .mt-4 > .container-lg > .row > .col-md-8 {
  1125. width: calc(100% - 450px);
  1126. }
  1127. #app > .mt-4 > .container-lg > .row > .col-md-4 {
  1128. width: 450px;
  1129. }
  1130. hr {
  1131. display: none;
  1132. }
  1133. /* highlight number of new comments */
  1134. .text-muted.fst-italic {
  1135. color: var(--bs-orange) !important;
  1136. }
  1137. /* Fix user drop down menu position*/
  1138. .dropdown-content {
  1139. right: 0px;
  1140. }
  1141. .dropdown-menu.show {
  1142. width: 100%;
  1143. }
  1144. /* Profile and Community Banner size */
  1145. .position-relative.mb-2 {
  1146. max-width: 730px;
  1147. }
  1148. /*table styles - primarily used on the "Communities" page*/
  1149. .table-responsive {
  1150. margin-top: 0.5em;
  1151. }
  1152. .table-sm td, .table-sm th {
  1153. padding: 0.1rem;
  1154. vertical-align: middle;
  1155. }
  1156. /**********************************************/
  1157. /** Specific screen size (mobile) adjustments */
  1158. /**********************************************/
  1159. @media screen and (min-width: 1981px) {
  1160. #app {
  1161. max-width: 1980px;
  1162. margin-left: auto;
  1163. margin-right: auto;
  1164. }
  1165. }
  1166. @media screen and (min-width: 1200px) and (max-width: 1640px) {
  1167. .col-md-4 {
  1168. flex: 0 0 25% !important;
  1169. max-width: 25%;
  1170. }
  1171. .col-md-8 {
  1172. flex: 0 0 75% !important;
  1173. max-width: 75%;
  1174. }
  1175. }
  1176. @media screen and (max-width: 1199px) and (min-width: 992px) {
  1177. .col-12 {
  1178. flex: 0 0 100% !important;
  1179. max-width: 75%;
  1180. }
  1181. .col-md-4 {
  1182. flex: 0 0 25% !important;
  1183. max-width: 25%;
  1184. }
  1185. .vote-bar {
  1186. flex: 0 0 8% !important;
  1187. max-width: 8% !important;
  1188. }
  1189. }
  1190. @media screen and (max-width: 768px) and (min-width: 576px) {
  1191. .col-12 {
  1192. flex: 0 0 100% !important;
  1193. max-width: 100%;
  1194. }
  1195. .col-sm-9 {
  1196. flex: 0 0 72% !important;
  1197. max-width: 72%;
  1198. }
  1199. .vote-bar {
  1200. flex: 0 0 8% !important;
  1201. max-width: 8% !important;
  1202. }
  1203. }
  1204. @media screen and (max-width: 575px) {
  1205. #tagline {
  1206. padding-right: 1em;
  1207. }
  1208. .col-12 {
  1209. flex: 0 0 100% !important;
  1210. max-width: 100%;
  1211. }
  1212. .col-8 {
  1213. flex: 0 0 75% !important;
  1214. max-width: 75%;
  1215. }
  1216. .col-4 {
  1217. flex: 0 0 25% !important;
  1218. max-width: 25%;
  1219. justify-content: flex-end !important;
  1220. display: flex !important;
  1221. }
  1222. }`
  1223.  
  1224. const styleTag = document.createElement('style');
  1225. styleTag.appendChild(document.createTextNode(css));
  1226. document.head.appendChild(styleTag);
  1227. /*append comment icon with "comment" text*/
  1228. var comm_count = document.querySelectorAll(".btn.btn-link.btn-sm.text-muted.ps-0");
  1229. comm_count.forEach(AppendCommentCountText);
  1230.  
  1231. /*Apply AppendCommentCountText to dynamically loaded elements */
  1232. ApplyCommentCountText(document.documentElement);
  1233.  
  1234. /*append post TLD link to post detail area*/
  1235. var post_info = document.querySelectorAll("article > .col-12.col-sm-9 > .row > .col-12");
  1236. post_info.forEach(AppendPostURL);
  1237.  
  1238. /* Apply AppendPostURL to dynamically loaded elements */
  1239. ApplyAppendPostURL(document.documentElement);
  1240. }
  1241. }`;
  1242.  
  1243. (function() {
  1244. 'use strict';
  1245. if(typeof $ == 'undefined'){ var $ = unsafeWindow.jQuery; }
  1246. let isLemmy;
  1247. try {
  1248. isLemmy = true;
  1249. isLemmy = document.head.querySelector("[name~=Description][content]").content === "Lemmy";
  1250. } catch (_er) {
  1251. isLemmy = false;
  1252. }
  1253.  
  1254. if (isLemmy) {
  1255. document.head.appendChild(document.createElement("script")).innerHTML = alienSiteOldStyle;
  1256. document.body.appendChild(document.createElement("script")).innerHTML = ltConfig;
  1257. document.head.appendChild(document.createElement("script")).innerHTML = funcs;
  1258. document.body.appendChild(document.createElement("script")).innerHTML = main;
  1259. }
  1260.  
  1261. })();