Softcobra Decoder (2021)

Decode links on softcobra.com and disable adblock detector

Per 15-08-2021. Zie de nieuwste versie.

/**
 * MIT License
 *
 * Copyright (c) 2021 GreatWizard
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */
// ==UserScript==
// @name            Softcobra Decoder (2021)
// @namespace       https://greasyfork.org/en/users/781676-greatwizard
// @version         0.10
// @description     Decode links on softcobra.com and disable adblock detector
// @author          GreatWizard (based on butforme and GlumWoodpecker work)
// @copyright       2021, GreatWizard (https://greasyfork.org/en/users/781676-greatwizard)
// @license         MIT
// @match           https://www.softcobra.com/*
// @grant           none
// @run-at          document-end
// @require         https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js
// ==/UserScript==

// ==OpenUserScript==
// @author          GreatWizard
// @collaborator    butforme
// @collaborator    GlumWoodpecker
// ==/OpenUserScript==

/* jshint esversion: 6 */
/* global CryptoJS */
setTimeout(function() {
  const message = document.getElementsByClassName('message')[0];
  const modal = document.getElementById("myModal");
  message.style.display = "none";
  modal.style.display = "none";
}, 1800);

const DEFAULT_STORE = {
  resolved: {}
};
const STORE_NAME = "__decoder__";

const base64RegExp = /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{4})$/;
const aesStart = "U2FsdGVkX1";

const formBody = (body) => {
  let data = [];
  for (let k in body) {
    data.push(`${encodeURIComponent(k)}=${encodeURIComponent(body[k])}`);
  }
  data = data.join("&");
  return data;
}


let store = localStorage.getItem('__decoder__');
if (store !== undefined) {
  store = Object.assign({}, DEFAULT_STORE, JSON.parse(store));
} else {
  store = DEFAULT_STORE;
}

(async () => {
  const tableRows = document.getElementsByTagName('td');
  for (let j = 0; j < tableRows.length; j++) {
    const currRow = tableRows[j].innerText;
    let decodedLink;
    let tryBase64 = currRow;
    try {
      let tryBase64Counter = 2;
      do {
        debugger
        tryBase64 = atob(tryBase64);
        tryBase64Counter--;
      } while (!tryBase64.startsWith("http") && tryBase64Counter > 0);
    } catch (e) {}
    if (store.resolved[currRow] !== undefined) {
      decodedLink = store.resolved[currRow];
    } else if (currRow.startsWith(aesStart)) {
      decodedLink = CryptoJS.AES.decrypt(currRow, "/").toString(CryptoJS.enc.Utf8);
    } else if (tryBase64.startsWith("http")) {
      decodedLink = tryBase64;
    } else if (currRow.match(base64RegExp)) {
      let response = await fetch("https://corsanywhere.herokuapp.com/https://nin10news.com/wp-content/themes/twentysixteen/inc/decode.php", {
        method: 'POST',
        headers: {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        body: formBody({
          data: currRow
        })
      });
      let body = await response.body;
      let data = await body.getReader().read();
      try {
        decodedLink = atob(new TextDecoder("utf-8").decode(data.value));
        window.__decoder__ = true;
      } catch (e) {
        console.log(`Impossible to decode ${currRow}`);
      }
    }
    if (decodedLink !== undefined) {
      tableRows[j].innerHTML = `<a href="${decodedLink}" target="_blank">${decodedLink}</a>`;
      store.resolved[currRow] = decodedLink;
      localStorage.setItem('__decoder__', JSON.stringify(store));
    }
  }
})();