soyaine / To Jike

// ==UserScript==
// @name         To Jike
// @namespace    http://lab.duoie.cc/
// @version      1.2
// @description  Go to web jike from share page.
// @author       未枝丫
// @copyright    2018, soyaine (https://github.com/soyaine)
// @license MIT
// @grant        none
// @include     https://m.okjike.com/*
// ==/UserScript==

function toJike() {
  var path = window.location.pathname.split('/');
  var type = path[1].slice(0, -1);

  if (type !== 'dailie' && type !== 'ho') {
    var banner = document.querySelector('div.top-banner__show');
    var btn = banner.querySelector('a.app-open-button');
    btn.remove();

    var toBtn = document.createElement('a');
    toBtn.className = "app-open-button jk-button jk-button-primary";
    toBtn.textContent = 'To Web';

    if (type === 'topic') {
      toBtn.href = `https://web.okjike.com/${type}/${path[2]}/official`;
    }
    else {
      toBtn.href = `https://web.okjike.com/${type}-detail/${path[2]}`;
    }

    banner.appendChild(toBtn);
  }
}

window.addEventListener("load", toJike);