My regular Javascript snippets: ```js window.q = (x,y=document) => y.querySelector(x) window.qq = (x,y=document) => Array.from(y.querySelectorAll(x)) ``` or ```js const q = (x,y=document) => y.querySelector(x) const qq = (x,y=document) => Array.from(y.querySelectorAll(x)) ``` ## Jquery CDN ```html ``` ## CORS Cross Origin PHP ```php header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Credentials: true"); header("Access-Control-Allow-Methods: GET,HEAD,OPTIONS,POST,PUT"); header("Access-Control-Allow-Headers: Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers"); ``` ## Random stuff Remove all stylesheets (nice to know this can be done dynamically; probably best to add select) ```js q("link") qq("link").forEach(x => x.remove()) ``` ## Chrome User Scripts (Tampermonkey) ```js // Generic element killer (function() { 'use strict'; const qq = (x) => Array.from(document.querySelectorAll(x)) const kl = (x) => qq(x).map((y) => y.parentNode.removeChild(y)) const kls = (x) => Array.from(x).map(kl) const klss = (x) => kls(x.split(" ")) setInterval(()=>{ klss("space separated list of selectors") },2000) // Your code here... })(); ``` ```js // @name BBC Football Score in Title Bar (function() { 'use strict'; // usual jquery-lite const q = (x,y=document) => y.querySelector(x) const qq = (x,y=document) => Array.from(y.querySelectorAll(x)) // score updater const tick = _ => { const home = q("section.sp-c-fixture--live-session-header .sp-c-fixture__number--home") const away = q("section.sp-c-fixture--live-session-header .sp-c-fixture__number--away") const homet = q("section.sp-c-fixture--live-session-header .sp-c-fixture__team-name--home abbr") const awayt = q("section.sp-c-fixture--live-session-header .sp-c-fixture__team-name--away abbr") const stat = q("section.sp-c-fixture--live-session-header .sp-c-fixture__status--live-sport-light") if( home && away && homet && awayt ) { document.title = `${home.textContent}-${away.textContent} ${stat.textContent} ${homet.textContent}-${awayt.textContent}` } } setInterval(tick,1000) })(); ``` #### Force Font Some sites have illegible font-faces (illegible on some machines). This hack does a mass-override. ```js for( x of document.querySelectorAll("*") ) { x.style.fontFamily = "sans-serif" } ```