Created
February 16, 2022 17:33
-
-
Save D3strukt0r/134204d4a11c8accabfb54b26a994a8d to your computer and use it in GitHub Desktop.
This file contains 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== | |
// @name BigCommerce Auto Puller | |
// @description Automaticall trigger all grabs on BigCommerce | |
// @namespace https://www.d3strukt0r.me | |
// @version 0.0.1 | |
// @author D3strukt0r | |
// @homepageURL https://github.com/D3strukt0r/BigCommerce-Auto-Grabber | |
// @icon https://icons.duckduckgo.com/ip2/bcm78789.com.ico | |
// @updateURL https://github.com/D3strukt0r/BigCommerce-Auto-Grabber/releases/latest/download/bigcommerce-auto-grabber.cjs.user.js | |
// @downloadURL https://github.com/D3strukt0r/BigCommerce-Auto-Grabber/releases/latest/download/bigcommerce-auto-grabber.cjs.user.js | |
// @supportURL https://github.com/D3strukt0r/BigCommerce-Auto-Grabber/issues | |
// @contributionURL https://github.com/sponsors/D3strukt0r | |
// @include /^https?://(www.)?bcm[0-9]{5}.com/ | |
// @require https://openuserjs.org/src/libs/sizzle/GM_config.js | |
// @license MIT | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// ==/UserScript== | |
"use strict";class e{static showConsole(){return GM_config.get("Debug")}static log(n){e.showConsole()&&console.log(n)}static debug(n){e.showConsole()&&console.debug(n)}static error(n){e.showConsole()&&console.error(n)}}function a(t){return new Promise(n=>{setTimeout(n,t)})}GM_config.init({id:"BigCommerce Auto Grabber",title:"Script Settings",fields:{Debug:{label:"Enable debugging",type:"checkbox",default:!1}}});let r=null,c=!1,s=null;const o=document.createElement("div");o.innerHTML="Auto Grab Running. CTRL + C to quit";o.style.position="fixed";o.style.top=`${5*16}px`;o.style.right=`${2*16}px`;o.style.backgroundColor="rgb(34, 34, 34)";o.style.color="rgb(255, 255, 255)";o.style.padding=`${1*16}px ${2*16}px`;o.style.zIndex="1";document.addEventListener("keydown",t=>{t.ctrlKey&&t.key==="c"&&c?(e.log("Disable auto grab"),c=!1,document.body.removeChild(o)):t.ctrlKey&&t.key===","&&GM_config.open()});async function l(){if(c){await a(250),e.log("Finding submit button ...");const t=document.querySelector(".check_order");if(t&&window.getComputedStyle(t).display==="block"){const n=t.querySelector(".btns .btn.submit:not(.disabled)");n===null?await l():(await a(250),e.log("Found submit button"),e.log(n),n.click(),await a(5e3),e.log("Connecting Observer ..."),s.observe(document.querySelector(".animation_layout"),{attributes:!0}),await l())}else await l()}}function w(t){e.log(t),s=new MutationObserver(n=>{(async()=>{for await(const i of n)e.log("Product image changed to:"),e.log(i.target),c&&i.type==="attributes"&&!i.target.getAttribute("imgurl").startsWith("/img/sucai_lihe")&&(e.log("Click on grab and disconnecting ..."),s.disconnect(),await a(250),r.click())})().catch(i=>{e.error(i)})}),e.log("Connecting Observer ..."),s.observe(document.querySelector(".animation_layout"),{attributes:!0}),t.addEventListener("click",()=>{(async()=>{e.log("Start auto puller ..."),c=!0,document.body.appendChild(o),await a(5e3),await l()})().catch(n=>{e.error(n)})},{once:!0})}async function d(){await a(250),r=document.querySelector(".grab_content .btns .bg-blue"),r===null?await d():(e.log("Found button:"),w(r))}window.history.pushState=(t=>function(...i){const u=t(...i);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),u})(window.history.pushState);window.history.replaceState=(t=>function(...i){const u=t(...i);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),u})(window.history.replaceState);window.addEventListener("popstate",()=>{window.dispatchEvent(new Event("locationchange"))});async function g(){window.location.hash.substring(1).startsWith("/grab")?(e.log("Switched to/Already on /grab. Finding button ..."),await d()):r=null}(async()=>{await g()})().catch(t=>{e.error(t)});window.addEventListener("locationchange",()=>{(async()=>{await g()})().catch(t=>{e.error(t)})}); |
This file contains 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== | |
// @name BigCommerce Auto Puller | |
// @description Automaticall trigger all grabs on BigCommerce | |
// @namespace https://www.d3strukt0r.me | |
// @version 0.0.1 | |
// @author D3strukt0r | |
// @homepageURL https://github.com/D3strukt0r/BigCommerce-Auto-Grabber | |
// @icon https://icons.duckduckgo.com/ip2/bcm78789.com.ico | |
// @updateURL https://github.com/D3strukt0r/BigCommerce-Auto-Grabber/releases/latest/download/bigcommerce-auto-grabber.cjs.user.js | |
// @downloadURL https://github.com/D3strukt0r/BigCommerce-Auto-Grabber/releases/latest/download/bigcommerce-auto-grabber.cjs.user.js | |
// @supportURL https://github.com/D3strukt0r/BigCommerce-Auto-Grabber/issues | |
// @contributionURL https://github.com/sponsors/D3strukt0r | |
// @include /^https?://(www.)?bcm[0-9]{5}.com/ | |
// @require https://openuserjs.org/src/libs/sizzle/GM_config.js | |
// @license MIT | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// ==/UserScript== | |
(function(t){typeof define=="function"&&define.amd?define(t):t()})(function(){"use strict";class t{static showConsole(){return GM_config.get("Debug")}static log(n){t.showConsole()&&console.log(n)}static debug(n){t.showConsole()&&console.debug(n)}static error(n){t.showConsole()&&console.error(n)}}function a(e){return new Promise(n=>{setTimeout(n,e)})}GM_config.init({id:"BigCommerce Auto Grabber",title:"Script Settings",fields:{Debug:{label:"Enable debugging",type:"checkbox",default:!1}}});let c=null,r=!1,s=null;const o=document.createElement("div");o.innerHTML="Auto Grab Running. CTRL + C to quit",o.style.position="fixed",o.style.top=`${5*16}px`,o.style.right=`${2*16}px`,o.style.backgroundColor="rgb(34, 34, 34)",o.style.color="rgb(255, 255, 255)",o.style.padding=`${1*16}px ${2*16}px`,o.style.zIndex="1",document.addEventListener("keydown",e=>{e.ctrlKey&&e.key==="c"&&r?(t.log("Disable auto grab"),r=!1,document.body.removeChild(o)):e.ctrlKey&&e.key===","&&GM_config.open()});async function l(){if(r){await a(250),t.log("Finding submit button ...");const e=document.querySelector(".check_order");if(e&&window.getComputedStyle(e).display==="block"){const n=e.querySelector(".btns .btn.submit:not(.disabled)");n===null?await l():(await a(250),t.log("Found submit button"),t.log(n),n.click(),await a(5e3),t.log("Connecting Observer ..."),s.observe(document.querySelector(".animation_layout"),{attributes:!0}),await l())}else await l()}}function w(e){t.log(e),s=new MutationObserver(n=>{(async()=>{for await(const i of n)t.log("Product image changed to:"),t.log(i.target),r&&i.type==="attributes"&&!i.target.getAttribute("imgurl").startsWith("/img/sucai_lihe")&&(t.log("Click on grab and disconnecting ..."),s.disconnect(),await a(250),c.click())})().catch(i=>{t.error(i)})}),t.log("Connecting Observer ..."),s.observe(document.querySelector(".animation_layout"),{attributes:!0}),e.addEventListener("click",()=>{(async()=>{t.log("Start auto puller ..."),r=!0,document.body.appendChild(o),await a(5e3),await l()})().catch(n=>{t.error(n)})},{once:!0})}async function d(){await a(250),c=document.querySelector(".grab_content .btns .bg-blue"),c===null?await d():(t.log("Found button:"),w(c))}window.history.pushState=(e=>function(...i){const u=e(...i);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),u})(window.history.pushState),window.history.replaceState=(e=>function(...i){const u=e(...i);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),u})(window.history.replaceState),window.addEventListener("popstate",()=>{window.dispatchEvent(new Event("locationchange"))});async function g(){window.location.hash.substring(1).startsWith("/grab")?(t.log("Switched to/Already on /grab. Finding button ..."),await d()):c=null}(async()=>{await g()})().catch(e=>{t.error(e)}),window.addEventListener("locationchange",()=>{(async()=>{await g()})().catch(e=>{t.error(e)})})}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment