Skip to content

Instantly share code, notes, and snippets.

@LeCoupa
Forked from papoms/fake-referrer.casper.js
Last active October 21, 2020 10:43
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LeCoupa/9873864 to your computer and use it in GitHub Desktop.
Save LeCoupa/9873864 to your computer and use it in GitHub Desktop.
How to fake the HTTP referer with CasperJS --> https://github.com/LeCoupa/awesome-cheatsheets
# Define Variables + Casper Initialization
fakeReferer = 'https://google.com/'
targetUrl = 'https://facebook.com/'
casper = require('casper').create()
# Fake the referer
casper.start fakeReferer, ->
@echo @getCurrentUrl()
casper.then ->
@evaluate (targetUrl) ->
link = document.createElement 'a'
link.setAttribute 'href', targetUrl
link.setAttribute 'id', 'myTargetUrl'
document.body.appendChild link
, targetUrl
casper.then ->
@click 'a#myTargetUrl'
casper.run ->
@echo @getCurrentUrl()
@exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment