Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    14
    Thanks
    3
    Thanked 1 Time in 1 Post
    Points: 6,016, Level: 50
    Points: 6,016, Level: 50
    Overall activity: 0%
    Overall activity: 0%
    Achievements:
    Veteran5000 Experience Points

    Post AS gallery view script

    Hello, I created a little script to display the threads in the download section as a gallery view, similar to other websites.
    It's a bit quick and dirty but works well so far. I thought i share it with you guys.

    To use it you will need a userscript manager like Tampermonkey.

    Here is the script, just copy it in a new entry.
    Tested with Tampermonkey and chrome/firefox.

    Code:
    // ==UserScript==
    // @name         [anime-sharing] gallery-view
    // @namespace    http://www.anime-sharing.com
    // @version      1
    // @description  Gallery View for anime-sharing. Very simple quick n diry script
    // @author       Regis|http://www.anime-sharing.com/forum/members/regis-41307/
    // @run-at       document-start
    
    // @match        http://www.anime-sharing.com/forum/hentai-games-38/*
    // @match        http://www.anime-sharing.com/forum/hentai-ovas-36/*
    // @match        http://www.anime-sharing.com/forum/hentai-manga-32/*
    // @match        http://www.anime-sharing.com/forum/light-novels-61/*
    // @match        http://www.anime-sharing.com/forum/raw-manga-30/*
    // @match        http://www.anime-sharing.com/forum/torrents-47/*
    
    // @require      https://code.jquery.com/jquery-3.3.0.min.js
    // @grant        GM_addStyle
    // ==/UserScript==
    
    (function() {
        'use strict';
    
        //USER OPTIONS START
    
        //How many days the NEW word ist displayed for a thread
        var threadAgeIsNew = 14;
    
        //How wide the one gallery is. Lets you display more/fewer items in a row. Default: 330 1K/ 337 4K
        var galleryItemWidth = 370;
    
        //USER OPTIONS END
    
        GM_addStyle(`
    
    #threadlist { display:none; }
    
    #thGalleryView { width: 100%; }
    .gvitem { float:left; width:${galleryItemWidth}px; height:310px; background:#f8f8f8; margin:5px; padding: 8px; border:1px solid #c4c4c4 }
    .gvitemtitle { height:50px; text-align: center; overflow: hidden; }
    .gvitemimg {
      height:225px;
      margin-bottom: 4px;
    }
    .gvitemimg > img {
    	max-width: calc(100% - 8px);;
    	max-height: calc(100% - 8px);
    	border: 2px solid #c8c8c8;
    	background: #fff;
    	padding: 2px;
    	display: block;
    	margin-left: auto;
    	margin-right: auto;
    }
    .newTh { color: #f3cd01; font-weight: bold; font-style: italic; text-shadow: 2px 2px 4px #7c6d33;margin-right:4px; }
        `);
    
        document.onreadystatechange = function () {
            if (document.readyState === "interactive") {
                start();
            }
        }
    
    
        function start() {
            createGViewer();
    
            $("#threadlist").find(".threadbit").each(function() {
                if ($(this).attr("id") == null)
                    return;
                var threadInfoObj = getThreadData($(this));
                addItemToView(threadInfoObj);
            });
        }
    
        function getThreadData(trObj) {
            var infoObj = {};
            infoObj.title = trObj.find(".threadtitle").find(".title").html().trim();
            infoObj.thread = trObj.find(".threadtitle").find("a.title").attr("href");
            infoObj.img = trObj.find("img.preview").attr("src");
            infoObj.authorHtml = trObj.find(".author").find(".username").removeClass("understate").prop('outerHTML');
            infoObj.lastPostHtml = trObj.find(".threadlastpost").find(".username").prop('outerHTML');
            infoObj.lastPostDate = parseDateInfo(trObj.find(".threadlastpost").find(".lastpostdate").parent().text().trim());
            infoObj.postDate = parseDateInfo(trObj.find(".author").find(".username").parent().text());;
            infoObj.isSticky = trObj.find(".threadtitle").find("img[title='Sticky Thread']").length > 0;
            infoObj.isNew = dateDiffInDays(infoObj.postDate, new Date()) < threadAgeIsNew;
    
            infoObj.lastPostStr = null;
            infoObj.infoStr = null;
    
            return infoObj;
        }
    
    
        function createGViewer() {
            var contHtml = `
              <div id='thGalleryView'>
              </div>
            `;
    
            $("#threadlist").before(contHtml);
        }
    
        function addItemToView(itemInfo) {
            var itemHtml = `
              <div class='gvitem'>
                <a href='${itemInfo.thread}'>
                  <div class='gvitemtitle' title='${itemInfo.title}'>
                    <span title='sticky thread' class='gvSticky' style='float:left; display:${disOpt(itemInfo.isSticky)}'>????</span>
                    <span style='display:${disOpt(itemInfo.isNew)}' class='newTh'>NEW</span>
                    <span>${itemInfo.title}</span>
                  </div>
                  <div class='gvitemimg'><img src='${itemInfo.img}' /></div>
                </a>
                <div class='gvitemInfo'>
                  <div><span>created by&nbsp;</span>${itemInfo.authorHtml}<span><span style='float:right'>last post by ${itemInfo.lastPostHtml}</span></div>
                  <div>on&nbsp;</span><span>${formatDate(itemInfo.postDate)}</span>
                       <span style='float:right'>on ${formatDate(itemInfo.lastPostDate)}</span></div>
                </div>
              </div>
            `;
    
            $("#thGalleryView").append(itemHtml);
        }
    
        function disOpt(isDisplay) {
            return (isDisplay ? "inline" : "none") ;
        }
    
        function formatDate(date) {
            if (date == undefined || date == null)
                return "";
    
            var dtstr = date.toLocaleDateString();
            dtstr += " " + ("0" + date.getHours()).slice(-2) + ":" + ("0" + date.getMinutes()).slice(-2);
    
            return dtstr;
        }
    
        function parseDateInfo(dstr) {
    
            var year, month, day, hour, min;
            if (dstr.includes("Yesterday") || dstr.includes("Today")) {
                var xdate = new Date();
                if (dstr.toLowerCase().includes("Yesterday"))
                    xdate.setDate(xdate.getDate() -1);
    
                year = xdate.getFullYear();
                month = xdate.getMonth();
                day = xdate.getDay();
                var regexTime = RegExp(/\d+\:\d+\s[AMP]+/, 'g');
                let matchArr = regexTime.exec(dstr);
                if (matchArr == null)
                    console.log("1-match failed-src:" + dstr + "|reg:" + regexTime);
    
                let timeStr = convertTime12to24(matchArr[0].trim());
                hour = timeStr.split(":")[0];
                min = timeStr.split(":")[1];
            }
            else {
                var regexDate = RegExp(/([A-z]+) (\d+)[A-z,\s]+(\d+)[,\s]([\d:\sAMP]+)/, 'g');
                //'Started by hentaigraal, August 7th, 2020 01:09 PM';
                let matchArr = regexDate.exec(dstr);
                if (matchArr == null)
                    console.log("2-match failed-src:" + dstr + "|reg:" + regexDate);
    
                var monthName = matchArr[1].trim().toLowerCase();
                var monthNameArr = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
                month = monthNameArr.indexOf(monthName.substr(0,3));
                day = matchArr[2].trim();
                year = matchArr[3].trim();
                let timeStr = convertTime12to24(matchArr[4].trim());
                hour = timeStr.split(":")[0];
                min = timeStr.split(":")[1];
            }
    
            return new Date(year, month, day, hour, min);
        }
    
        //Input: 01:09 PM | output: 13:09
        function convertTime12to24(time12h) {
            let [time, modifier] = time12h.split(' ');
            let [hours, minutes] = time.split(':');
            if (hours === '12') {
                hours = '00';
            }
    
            if (modifier === 'PM') {
                hours = parseInt(hours, 10) + 12;
            }
    
            return `${hours}:${minutes}`;
        }
    
        function dateDiffInDays(first, second) {
            return Math.round((second-first)/(1000*60*60*24));
        }
    
    })();
    Last edited by Regis; August 19th, 2020 at 05:17 PM.

  2. # ADS
    Circuit advertisement
    Join Date
    Always
    Posts
    Many
     

  3. #2
    ピュア&イノセント Checkmate's Avatar
    Join Date
    Oct 2010
    Location
    Castle Groundgroup
    Posts
    6,744
    Thanks
    205
    Thanked 5,275 Times in 849 Posts
    Points: 158,859, Level: 100
    Points: 158,859, Level: 100
    Overall activity: 2.0%
    Overall activity: 2.0%
    Achievements:
    Three FriendsOverdriveRecommendation First ClassTagger Second ClassVeteran50000 Experience Points

    Re: AS gallery view script

    Did you mean the grid view?

    In the next major rehaul dubbed the AS Community 2.0, I'll make some section to displayed as Grid. It is still under development since it was a lot bigger than I originally planned.

    I only post what I bought. My uploads are for those who share the same taste but could not easily import them. If you can buy the game, please do it to support the company.
    Bugs report belong to the Site Support, not my inbox.

  4. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    14
    Thanks
    3
    Thanked 1 Time in 1 Post
    Points: 6,016, Level: 50
    Points: 6,016, Level: 50
    Overall activity: 0%
    Overall activity: 0%
    Achievements:
    Veteran5000 Experience Points

    Re: AS gallery view script

    yea, some call it gallery view, others grid view. Since there hasnt been one for such a long time, i made a script for that.

  5. #4
    Junior Member
    Join Date
    Nov 2017
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Points: 2,131, Level: 27
    Points: 2,131, Level: 27
    Overall activity: 0%
    Overall activity: 0%
    Achievements:
    1 year registered1000 Experience Points

    Re: AS gallery view script

    nie grid view, thank you for having me get some information here.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Ongoing AS Uploads
    By corocoro in forum Ongoing Series
    Replies: 1
    Last Post: December 23rd, 2012, 11:45 AM
  2. Favourite artist(s) or circle(s) - as in drawings?
    By Ignis in forum General Discussions & Debates
    Replies: 7
    Last Post: June 24th, 2011, 12:23 AM
  3. AS IRC Channel
    By corocoro in forum Announcements & News
    Replies: 0
    Last Post: February 13th, 2011, 08:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •