Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I create a custom tip button for my own website? #71

Open
loureirorg opened this issue May 16, 2022 · 1 comment
Open

Can I create a custom tip button for my own website? #71

loureirorg opened this issue May 16, 2022 · 1 comment

Comments

@loureirorg
Copy link

Is it possible to adapt brave-site-specific-scripts code to create a custom tip button for my own website?

Let's say I put the port.postMessage call, from github/tipping.ts, on a button on my website:

port.postMessage({
type: 'TipUser',
mediaType: types.mediaType,
data: {
url: profileUrl,
publisherKey,
publisherName,
publisherScreenName,
favIconUrl: mediaMetaData.user.favIconUrl,
postId: mediaMetaData.post.id,
postTimestamp: mediaMetaData.post.timestamp,
postText: mediaMetaData.post.text
}
})
}

And replace the variables with my publisher data (plus other JS code like port), will it work?

I'm thinking to create a WordPress plugin so people can add a "Donate with Brave" button on their pages.

PS: Sorry in advance if this is not the right place for this kind of question. Let me know if there is a better place to ask this.

@loureirorg loureirorg changed the title Can I create a custom tip button for my own website Can I create a custom tip button for my own website? May 16, 2022
@loureirorg
Copy link
Author

Interesting, I get a Could not establish connection. Receiving end does not exist. when I try to connect to Brave extension:

const braveExtensionId = 'mnojpmjdmbbfmejpflffifhffcmidifd'
chrome.runtime.sendMessage(
  braveExtensionId, 
  { type: 'SupportsGreaselion' }, 
  (response) => console.log(chrome.runtime.lastError)
)

I get the same error if I try to connect to the Rewards extension with:

const braveRewardsExtensionId = 'jidkidbbcafjabdphckchenhfomhnfma'
chrome.runtime.connect(
  braveRewardsExtensionId, 
  { name: 'Greaselion' }
)

As this connection is necessary for creating the port object, I think I won't be able to create the custom tip button.

I wonder if there's a limitation preventing access to the Brave extension outside "brave-site-specific-scripts" or if is just me doing something wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant