-
-
Save dterracino/31548ae7f70b484d0be9b2192ca8f77a to your computer and use it in GitHub Desktop.
fanatica-key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @author MoaMoa | |
// @name fanatical keyextract | |
// @namespace http://tampermonkey.net/ | |
// @version 0.4 | |
// @description fanatical keyextract | |
// @include https://www.fanatical.com/*/orders | |
// @require https://cdn.bootcss.com/jquery/3.5.0/jquery.slim.min.js | |
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js | |
// @grant GM_setClipboard | |
// @grant GM_addStyle | |
// ==/UserScript== | |
(function() { | |
GM_addStyle(`.button1 { | |
width: 50px; | |
height: 40px; | |
background: linear-gradient(to bottom, #4eb5e5 0%,#389ed5 100%); /* W3C */ | |
border: none; | |
border-radius: 5px; | |
position: relative; | |
border-bottom: 4px solid #2b8bc6; | |
color: #fbfbfb; | |
font-weight: 600; | |
font-family: 'Open Sans', sans-serif; | |
text-shadow: 1px 1px 1px rgba(0,0,0,.4); | |
font-size: 15px; | |
text-align: left; | |
text-indent: 5px; | |
box-shadow: 0px 3px 0px 0px rgba(0,0,0,.2); | |
cursor: pointer; | |
/* Just for presentation */ | |
margin: 0 auto; | |
margin-left: 10px; | |
} | |
.button3:active { | |
box-shadow: 0px 2px 0px 0px rgba(0,0,0,.2); | |
top: 1px; | |
} | |
.button4:active { | |
box-shadow: 0px 2px 0px 0px rgba(0,0,0,.2); | |
top: 1px; | |
} | |
.selector-SIM{ | |
height: 40px; | |
line-height: 40px; | |
padding: 0 15px; | |
transition: border-color .2s cubic-bezier(.645,.045,.355,1); | |
} | |
`) | |
waitForKeyElements ('[class="text-right col-md-6"]', actionFunction); | |
const $Scrape = $('<button class="button-reveal-SIM button1 button3">Scrape</button>').toArray()[0]; | |
const $Copy = $('<button class="button-copy-SIM button1 button4">Copy</button>').toArray()[0]; | |
const $select=$('<select name="gameName" class="selector-SIM"><option value="yes">Copy Game Name</option><option value="no" selected="selected">不复制游戏名</option><option value="nameCopy">只复制游戏名</option></select>').toArray()[0] | |
function init(){ | |
$( ".button-reveal-SIM" ).click(function() { | |
$('[class="btn btn-secondary btn-block"]').trigger("click"); | |
}); | |
$( ".button-copy-SIM" ).click(function() { | |
let arr =$(".order-item-details-container").find(".game-name").toArray() | |
let arr1 =$(".order-item-details-container").find("input[type='text']").toArray() | |
let str ='' | |
let gameName = $(".selector-SIM").val() | |
arr1.forEach((item,index)=>{ | |
if(gameName=="yes"){ | |
str+=arr[index].innerHTML+": "+ item.value+ "\n" | |
} else if(gameName=="no") { | |
str+=item.value+ "\n" | |
} else if(gameName=="nameCopy") { | |
str+=arr[index].innerHTML+ "\n" | |
} | |
}) | |
GM_setClipboard(str); | |
}); | |
} | |
function actionFunction (jNode) { | |
jNode.append($select) | |
jNode.append($Scrape) | |
jNode.append($Copy) | |
init() | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment