Obtain direct, clickable AceStream links on PlatinSport, bypassing url shorteners.
目前為
// ==UserScript==
// @name PlatinSport direct AceStream links
// @description Obtain direct, clickable AceStream links on PlatinSport, bypassing url shorteners.
// @namespace StephenP
// @author StephenP
// @grant GM.registerMenuCommand
// @grant GM.setValue
// @grant GM.getValue
// @version 1.1
// @match https://www.platinsport.com/*
// @contributionURL https://nowpayments.io/donation/stephenpgreasyfork
// @license AGPL-3.0-or-later
// ==/UserScript==
getAdultContentVisible();
async function getAdultContentVisible(){
var x=await GM.getValue("adultContentEnabled");
if(x=="yes"){
GM.registerMenuCommand("Hide the lists of adult contents on Platinsport", hideAdultContent, "H");
}
else{
GM.registerMenuCommand("Show the lists of adult contents on Platinsport", showAdultContent, "S");
removeAdultLinks();
}
createLinks();
}
function hideAdultContent(){
GM.setValue("adultContentEnabled","no");
location.reload();
}
function showAdultContent(){
GM.setValue("adultContentEnabled","yes");
location.reload();
}
function removeAdultLinks(){
var b=document.getElementsByClassName("fa-mars-double");
if(b.length==1){
b[0].parentNode.parentNode.remove();
}
}
function createLinks(){
if(!document.location.href.includes("/link/")){
var links=document.getElementsByTagName("A");
for(let link of links){
if(link.href.includes("bc.vc")){
let pos=link.href.indexOf("https://www.p");
link.href=link.href.slice(pos);
}
}
}
else{
var texts=document.getElementsByTagName("STRONG");
for(let t of texts){
var link=null;
var regexpLinks=/acestream:\/\/[a-f0-9]{40}/g
t.innerHTML=t.innerHTML.replace(regexpLinks,replacerLinks);
if(location.href.includes("/link")){
var regexpLangs=/[\[]([A-Z][A-Z])[\]]/g
t.innerHTML=t.innerHTML.replace(regexpLangs,replacerLangs);
}
}
}
}
function replacerLinks(match, offset, string) {
return "<a style=\"color: yellow; line-height: normal\" href=\""+match+"\">"+match.replace("acestream://","")+"</a>";
}
function replacerLangs(match, p1, offset, string) {
return getFlagEmoji(p1);
}
//Following function taken mostly from https://dev.to/jorik/country-code-to-flag-emoji-a21
function getFlagEmoji(countryCode) {
if(countryCode==="UK"){
countryCode="GB"
}
const codePoints = countryCode
.toUpperCase()
.split('')
.map(char => 127397 + char.charCodeAt());
return String.fromCodePoint(...codePoints);
}