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

no double-click event, trigger immediately #684

Open
DandyClubs opened this issue Feb 27, 2024 · 2 comments
Open

no double-click event, trigger immediately #684

DandyClubs opened this issue Feb 27, 2024 · 2 comments

Comments

@DandyClubs
Copy link

i add some scripts search

function openNewBackgroundTab(url){
    var a = document.createElement("a");
    a.href = url
    var evt = document.createEvent("MouseEvents");
    //the tenth parameter of initMouseEvent sets ctrl key
    evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,
                                true, false, false, false, 0, null);
    a.dispatchEvent(evt);
}


        let searchText = (Text) => {
            let SearchWord = Text.replace(/\s&\s/g, ' ').split(/\s-\s/)
            SearchWord = SearchWord.map(e => e.replace(/\n/g, '').trim())
            SearchWord[0] = SearchWord[0].replace(/[^[:alnum:]]/g, '').replace(/\s/g, '')
            SearchWord[0] = /\s-\s/.test(Text) ? SearchWord[0] : Text
            return SearchWord.join(' ')
        }
var url = 'https://therarbg.com/get-posts/keywords:' + searchText(searchTerms) 


function openInNewTab(href) {
  Object.assign(document.createElement('a'), {
    target: '_blank',
    rel: 'noopener noreferrer',
    href: href,
  }).click();
}

var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if(!is_chrome)
{
    openInNewTab(url)
} else {
    openNewBackgroundTab(url);
}

some add search script

text select

quick menu

script search click.... and new tab open.

and quick menu other script search icon click...

console

no double-click event, trigger immediately

i use firefox

edge not work open background tab

so i make script search

@ssborbis
Copy link
Owner

That message you are seeing no double-click event, trigger immediately is indicating that you don't have a double-click search action also assigned to the mouse button you are using, and therefore the addon won't wait to check for a second click event on the search engine. Instead, it will trigger the search immediately on the first click.

Did you have another question regarding your script? Also, is the background tab issue with Edge happening only with your script, or with this addon? I'll check also.

@DandyClubs
Copy link
Author

DandyClubs commented Mar 1, 2024

A script search
B script search

text select

quick menu A or B click

first script search icon click work

but not work when script search icon click until page reload

just console.log no double-click event, trigger immediately

Edge quick menu search icon new tab open and focus search tab

not work background tab open

so i try script

i try

 let searchText = (Text) => {
            let SearchWord = Text.replace(/\s&\s/g, ' ').split(/\s-\s/)
            SearchWord = SearchWord.map(e => e.replace(/\n/g, '').trim())
            SearchWord[0] = SearchWord[0].replace(/[^[:alnum:]]/g, '').replace(/\s/g, '')
            SearchWord[0] = /\s-\s/.test(Text) ? SearchWord[0] : Text
            return SearchWord.join(' ')
        }

to

function searchText(Text){
            let SearchWord = Text.replace(/\s&\s/g, ' ').split(/\s-\s/)
            SearchWord = SearchWord.map(e => e.replace(/\n/g, '').trim())
            SearchWord[0] = SearchWord[0].replace(/[^[:alnum:]]/g, '').replace(/\s/g, '')
            SearchWord[0] = /\s-\s/.test(Text) ? SearchWord[0] : Text
            return SearchWord.join(' ')
        }

so fine work

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

2 participants