How do I make a script to redirect discord resources from cdn.discordapp.net to media.discordapp.com? - tampermonkey

When trying to go to discord, I face the issue of profile pictures, custom emotes and various other things not loading, while the main functionality of discord, and uploaded picures work perfectly.
I have narrowed it down to being an issue with the "cdn.discordapp.net/" link. Meanwhile "media.discordapp.com" works perfectly, and when I replace the resource links with the media one, it loads perfectly.
My question is then: can I make a tampermonkey script to redirect cdn.discordapp.net links to media.discordapp.com instead?

Related

How to know which element receives the click()?

I am writing a script that goes to an Amazon URL and clicks on the 'Buy Now' button. That's it. I have to use WebdriverIO, javascript, and ChromeDriver. The problem is that I can't get this button to be clicked no matter which selector I use. I am able to manually do it just fine. But in the Code Inspect below, every combination of div/id/name, span/id/close, or input/id/name has resulted in no clicks. I know the script can see that web object because when I do a BuyNow.getText() to console, it prints out 'Buy Now'. And I know the xpath I use is good because I paste it into Inspect/Find and the exact element lights up yellow. Oh and the .click(), even though Visual Studio Code flags as deprecated, works just fine in previous scripts.
When I manually click on a button, is there a way to see what was the exact element that received this click?
let BuyNow = $(<XPATH>)
BuyNow.click()
Code Inspect
Ok so I found out what the problem was. It had nothing to do with my XPATH selectors, any one of which to the elements in the Code Inspect picture would have worked (example: let BuyNow = *[id='buy-now-button']). The issue is that in the WDIO config file, I had a custom Chrome Profile being used. Which is fine, the Chrome.exe I was using was pointing to another custom Chrome Profile. I thought these two were the same, but the folders paths were getting messed up. Once I resolved them, and had both the Chrome.Exe and WDIO config pointing to the same customer folder, Chrome started to allow me to select buttons. I think that the WDIO code was looking at one user profile of chrome, and the desktop chrome browser that I was using was another user profile.
Solved. Fun Stuff but not really.

Duplicate in Gatsby path to markdown file for blog post

I am editing this Gatsby starter to make a personal website: https://www.gatsbyjs.org/starters/rolwin100/rolwinreevan_gatsby_blog/
Note that the problem I'm having with my site also happens when I develop the starter (with no changes made).
My desired outcome is pretty simple, I just want to be able to click on a blog post at site-name.com/blog/post-name that works. So, I set the path in my markdown files to be blog/post-name, replicating the starter exactly. However, when I run gatsby develop and click on the posts, the weirdest thing happens, For ex, from running the starter I get: There's not a page yet at /blog/blog/code-splitting-in-react (pictured fully below). But the page /blog/code-splitting-in-react does exist and when you adjust the url to that it brings up the page perfectly.
So the question is-- where is that extra 'blog' coming from in the path and how do I get rid of it??
error messages when I click on a blog post
You said that you are setting the url to blog/post-name. That is a relative path. It is going to start from whatever url you currently are. For example if you are in http://example.com/bla/foo you'll end in http://example.com/bla/foo/blog/post-name. You need to add a slash at the beginning: /blog/post-name.

Refreshing React page

I'm back (Refreshing React with Express server). I am hoping to figure out this issue.
Quick recap: I am trying to refresh my react website. If I go to www.domain.com/about I will get the:
Not Found
The requested URL was not found on this server.
same if I click on the button to get to /about and hit refresh I will get this error.
My goal
To be able to go to my site, click on another page (i.e. domain.com/anotherpage) hit f5 for refresh and get the same page.
I understand:
The problem is that React just changes the URL when I click on my React app button or link to go to a different page. Then when I refresh it looks for www.domain.com/whatever. Since there is nothing for it, it returns 404.
I also know that if I can get my React app to direct all traffic to index.html. React will handle the rest.
What I have tried:
In my previous post, it was suggested to use my hosting site to redirect traffic to index.html. However, my hosting site lets me adjust the DNS for subdomains but nothing after it. (ie. www.subdomain.domain.com works fine but www.domain.com/whatever doesn't) which I expected but I thought I would try.
I do have an express app however, it doesn't serve the files it just waits for a button to be pressed and then does stuff. I don't need to the server to run to have the website up.
I have tried creating a route in express for this and it looks like:
app.get('/*', (req, res) =>{
res.sendFile(path.join(__dirname + '/public/index.html'));
});
I still get the same 404 error with this.
I have also added an index.html to my server. Thinking it needed the .html file to send. (Thought it might be good).
What I don't know
Where does React look for index.html in production? When I look in the build files under asset-manifest.json there is an "index.html": "/index.html" line of code. Is there where it finds the index file? If so, can I change this to go to index.html on every page request?
Obviously I want the user to be able to refresh the page and get back to it. Can someone point me in the right direction?
Thanks in advance!

LinkedIn share links to PDF documents

I am trying to create buttons on a web page that allow users to share links to PDF documents on LinkedIn. LinkedIn loads a window without any errors but offers no link or preview of the PDF or any indication of what is being shared.
Here are the two methods I have tried. First the plugin method.
<script type="in/share" data-url="http://example.net/DocumentDownload.aspx?Command=Core_Download&entryID=114"></script>
And, secondly with a custom url.
TEST
Encoding the url makes no difference.
The above links are direct document links from a DNN web site using Document Exchange. If I change the urls to any html page it works fine and LinkedIn seems to be able to extract the useful information right from the page and use that for the share details.
Can LinkedIn handle this kind of thing? There is nothing to guide me on the type of links that can be shared. I can't find any information about it. There are no errors in the web console.
Not sure, but you should try to provide LinkedIn with the link that has .pdf at the end, like http://example.com/documents/file1.pdf. I guess LinkedIn just checks the URL if it has .pdf file at the end to decide if it is a PDF document or not.
I have no problem sharing pdf's on LinkedIn. Check it out...
https://www.linkedin.com/sharing/share-offsite/?url=https://www.revoltlib.com/anarchism/the-conquest-of-bread/view.pdf
Works perfectly fine. And view.pdf is a script, not a file, either, so, it's not looking for a PDF file to analyze, so much as headers that indicate you have a PDF file available to analyze, so, in PHP, at DocumentDownload.aspx, we would do...
header('Content-type: application/pdf; charset=utf-8');
This header let's the sharing app know that it can analyze the document as a PDF file and extract useful information from it, as you can see from the screen shot.

How can I implement the facebook authentication in a MEAN application preventing CORS problems?

I'm implementing an application using the full MEAN stack.
I created a login page to signup with facebook to be able to show a profile page. But I discovered some problems. For this reason, I created a smaller version of my webapp, maintaining the same project structure.
The complete code, executable (only replacing "client id" and "secret") with "npm install" and after "nodemon" is available here: https://github.com/Ks89/MEAN-OAuth_Example
If I'll call (with a browser) the rest API that I created to login with facebook at "http://localhost:3000/api/auth/facebook", everything will be ok!
But if I'll want to do the same thing, clicking on the "Login" button, I'll receive the error as in figure:
I know that the problem is related to CORS, but how can I'll fix this in my application, maintaining the same project structure?
I don't want to put the "rest path" inside the HTML. I tried for many days different solutions without success.
If you want, experiment directly on my application that I created exactly to write this question ;).
If really necessary, I'll able to post the entire source code here, but I prefer an organized and executable code into a repository for this particular question.
Please, give me some ideas and hopefully a solution, because I'm really blocked.
The example routes from the passport-facebook repo are intended for multipage apps, not ajax requests. If you look at what those routes are doing, /auth/facebook is just a redirect to Facebook where the user is expected to log in if necessary and authorize your application. When you make that same request from angular, it follows the redirect and tries to load the Facebook page, but the browser blocks you as your console screenshot shows. CORS would be relevant if Facebook wanted to allow you to request their login form across origins, but they don't because that would basically make you a phisher.
It looks like you're trying to handle authentication without leaving the page, but at some point you're going to need the user to leave your site and be redirected to Facebook in order to complete the OAuth flow. You can either open a pop-up containing the Facebook OAuth dialog (it looks like this is what the Facebook JavaScript SDK does by default) or just use your app's current tab with something as simple as <a ng-href="{{facebookOauthUrl}}">Log in with Facebook</a>.

Resources