diff --git a/src/js/background.js b/src/js/background.js index d9072d029..12a663a44 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -64,17 +64,6 @@ brws.runtime.onInstalled.addListener(details=>{ { brws.tabs.create({url:"https://fastforward.team/firstrun"}) } - //init clipboard - chrome.storage.local.get({ff_clipboard: "{}"}, function(data) { - chrome.storage.local.set({ff_clipboard: data.ff_clipboard}, function() { - })}) -}) - -//clean clipboard on startup -brws.runtime.onStartup.addListener(() => { - chrome.storage.local.get({ff_clipboard: "{}"}, function(data) { - chrome.storage.local.set({ff_clipboard: data.ff_clipboard}, function() { - })}) }) // Uninstall handler diff --git a/src/js/content_script.js b/src/js/content_script.js index 7d338d856..4cb399a31 100644 --- a/src/js/content_script.js +++ b/src/js/content_script.js @@ -1,5 +1,5 @@ //If you want to add your own bypass, go to injection_script.js -if(document instanceof Document) +if(document instanceof HTMLDocument) { let clipboardIndex=location.hash.indexOf("#bypassClipboard="),ignoreCrowdBypass=false,bypassClipboard="" if(location.hash.substr(-18)=="#ignoreCrowdBypass") @@ -117,36 +117,19 @@ if(document instanceof Document) crowdPath=location.pathname.substr(1), referer=location.href - //ffclipboard reciever - window.addEventListener("message", function(event) { - // We only accept messages from ourselves - if (event.source != window) { - return; - } - if (event.data.type === "ffclipboardSet") { - brws.storage.local.set({ff_clipboard: event.data.text}) + let script=document.createElement("script") + script.innerHTML=`(()=>{ + const crowdEnabled=`+(res.crowdEnabled?"true":"false")+`, + ignoreCrowdBypass=`+(ignoreCrowdBypass?"true":"false")+`, + bypassClipboard="`+bypassClipboard.split("\\").join("\\\\").split("\"").join("\\\"")+`" + if(location.href=="https://universal-bypass.org/firstrun") + { + location.replace("https://universal-bypass.org/firstrun?1") + return } - }); - brws.storage.local.get('ff_clipboard', function(result) { - ffClipboard_stored = result.ff_clipboard - - //encodeURIcomponent and replace whatever's not encoded, https://stackoverflow.com/a/16435373/17117909 - ffClipboard_stored = encodeURIComponent(ffClipboard_stored).replace(/\-/g, "%2D").replace(/\_/g, "%5F").replace(/\./g, "%2E").replace(/\!/g, "%21").replace(/\~/g, "%7E").replace(/\*/g, "%2A").replace(/\'/g, "%27").replace(/\(/g, "%28").replace(/\)/g, "%29") - let script=document.createElement("script") - script.innerHTML=`(()=>{ - const crowdEnabled=`+(res.crowdEnabled?"true":"false")+`, - ignoreCrowdBypass=`+(ignoreCrowdBypass?"true":"false")+`, - bypassClipboard="`+bypassClipboard.split("\\").join("\\\\").split("\"").join("\\\"")+`" - let ffClipboard_stored="`+ffClipboard_stored+`" - if(location.href=="https://universal-bypass.org/firstrun") - { - location.replace("https://universal-bypass.org/firstrun?1") - return - } - `+res.injectionScript+` - })()` - script=document.documentElement.appendChild(script) - setTimeout(()=>document.documentElement.removeChild(script),10) - }); + `+res.injectionScript+` + })()` + script=document.documentElement.appendChild(script) + setTimeout(()=>document.documentElement.removeChild(script),10) }) } diff --git a/src/js/injection_script.js b/src/js/injection_script.js index 2725ff00c..8cc31294e 100644 --- a/src/js/injection_script.js +++ b/src/js/injection_script.js @@ -298,84 +298,7 @@ backgroundScriptBypassClipboard=c=>{ persistHash=h=>ensureDomLoaded(()=>{ document.querySelectorAll("form[action]").forEach(e=>e.action+="#"+h) document.querySelectorAll("a[href]").forEach(e=>e.href+="#"+h) -}), -//decodes https://stackoverflow.com/a/16435373/17117909 -decodeURIEncodedMod=(s)=>{ - try{ - return decodeURIComponent(s.replace(/\%2D/g, "-").replace(/\%5F/g, "_").replace(/\%2E/g, ".").replace(/\%21/g, "!").replace(/\%7E/g, "~").replace(/\%2A/g, "*").replace(/\%27/g, "'").replace(/\%28/g, "(").replace(/\%29/g, ")")); - }catch (e) { - return null - } -} - -//Backwards compatibility for ffclipboard -versionString = UNIVERSAL_BYPASS_EXTERNAL_VERSION + '' -let versionPatchNumber = Number(versionString.split(".").pop()) -let ffClpbrdSupported = false -if(versionPatchNumber >= 1924) { - ffClpbrdSupported = true -} -if (ffClpbrdSupported) { - ffClipboard_stored = decodeURIEncodedMod(ffClipboard_stored) //ffClipboard_stored is defined in content_script.js -} else { - ffClipboard_stored = '{}' -} -class ffClipboard { - constructor() { } - //returns an ffclipboard entry, if id does not exist, returns null - static get(id) { - try { - var ffClipboardObj = JSON.parse(ffClipboard_stored) - } catch (e) { - return null - } - if (ffClipboardObj) { - if (ffClipboardObj[id]) { - return ffClipboardObj[id] - } else { - return null - } - } else { - return null - } - } - //sets ffclipboard contents, if id does not exist, creates it - static set(id, value) { - try { - var ffClipboardObj = JSON.parse(ffClipboard_stored) - } catch (e) { - return null - } - if (ffClipboardObj) { - ffClipboardObj[id] = value - let message = { type: "ffclipboardSet", text: JSON.stringify(ffClipboardObj) } - window.postMessage(message, "*") //send message to content script - ffClipboard_stored = JSON.stringify(ffClipboardObj) - } else { - return null - } - } - //deletes ffclipboard contents and frees up storage, if id does not exist, does nothing - static free(id) { - try { - var ffClipboardObj = JSON.parse(ffClipboard_stored) - } catch (e) { - return null - } - if (ffClipboardObj) { - if (ffClipboardObj[id]) { - delete ffClipboardObj[id] - let message = { type: "ffclipboardSet", text: JSON.stringify(ffClipboardObj) } - window.postMessage(message, "*") - ffClipboard_stored = JSON.stringify(ffClipboardObj) - } else { - return - } - } else { - return - } - } -} +}) let navigated=false, bypassed=false, domain=location.hostname,