Mobile01 pager icon

Add 'prev page/next page' icon.

目前為 2019-08-22 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Mobile01 pager icon
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add 'prev page/next page' icon.
// @author       You
// @match        https://www.mobile01.com/topicdetail.php?*
// @grant        none
// @require http://code.jquery.com/jquery-3.4.1.min.js

// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    var prev = $("li.l-pagination__page.is-active").prev()[0];
    var next = $("li.l-pagination__page.is-active").next()[0];
    var prev_url, next_url;
    var prev_html = "<div class='m01_pager' style='font-size:5em; width:70pt; text-align:center; font-family:monospace; border-radius:50%; position:fixed; top:40%; left:10%;background:#aaa; opacity:.5;'><a href><span style='color:#fff; display:block;'>&lt;</span></a></div>";
    var next_html = "<div class='m01_pager' style='font-size:5em; width:70pt; text-align:center; font-family:monospace; border-radius:50%; position:fixed; top:40%; right:15%;background:#aaa; opacity:.5;'><a href><span style='color:#fff; display:block;'>&gt;</span></a></div>";


    prev_url = prev ? $('a', prev).attr('href') : "";
    next_url = next ? $('a', next).attr('href') : "";

    console.log(prev,next);
    console.log('prev_url = ' + prev_url);
    console.log('next_url = ' + next_url);

    if (prev_url != "")
    {
        var prev_icon = $(prev_html);
        $('a', prev_icon).attr("href", prev_url);
        $(prev_icon).appendTo("body");

    }

    if (next_url != "")
    {
        var next_icon = $(next_html);
        $('a', next_icon).attr("href", next_url);
        $(next_icon).appendTo("body");

    }
})();