IGG-Games/MPC-G Skiper

Skip wating AD page in IGG games download link

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         IGG-Games/MPC-G Skiper
// @namespace    https://greasyfork.org/zh-TW/scripts/19802-igg-games-mpc-g-skiper
// @version      2.5
// @description  Skip wating AD page in IGG games download link
// @author       Yu-Hsin Lu
// @include      http://igg-games.com/*
// @require      https://cdn.jsdelivr.net/lodash/4.17.4/lodash.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.10/clipboard.min.js
// @grant        unsafeWindow
// ==/UserScript==

// Global patten
const URLpat = /.*bluemediafiles.com.*?xurl=(.*)$/i;
const googlepat = /drive\.google\.com/;
const megapat = /mega\.nz/;

(function() {
    // Create panel
    new Clipboard('.clipboard');
    const titleElement = document.querySelector('h1.title');
    const megaButton = document.createElement('button');
    megaButton.classList.add("clipboard");
    titleElement.append(document.createElement('br'));
    megaButton.id = "mega";
    megaButton.innerHTML = "Copy all mega download link";
    titleElement.append(megaButton);
    titleElement.append(document.createElement('br'));
    const googleButton = document.createElement('button');
    googleButton.classList.add("clipboard");
    googleButton.id = "google";
    googleButton.innerHTML = "Copy all google download link";
    titleElement.append(googleButton);

    let collections = {mega: [],google: []};
    let anchors = document.querySelectorAll('a');
    anchors = Array.apply(null, anchors);
    let all_downloadlinks = anchors.filter(anchor => URLpat.test(anchor.href)).map(anchor => {
        const downloadlink = `http${URLpat.exec(anchor.href)[1]}`;
        anchor.href = downloadlink;
        return downloadlink;
    });
    all_downloadlinks.filter(downloadlink => googlepat.test(downloadlink)).forEach(downloadlink => collections.google.push(downloadlink));
    all_downloadlinks.filter(downloadlink => megapat.test(downloadlink)).forEach(downloadlink => collections.mega.push(downloadlink));
    document.querySelector('#mega').innerHTML = "Copy All Mega Link";
    document.querySelector('#mega').setAttribute("data-clipboard-text", collections.mega.join("\n"));
    document.querySelector('#google').innerHTML = "Copy All Google Link";
    document.querySelector('#google').setAttribute("data-clipboard-text", collections.google.join("\n"));
})();