Greasy Fork is available in English.

讨论 » 创建请求

Multilogin equivalent for tampermonkey script

§
发表于:2015-04-24

Multilogin equivalent for tampermonkey script

I maintain this old script project Neverwinter gateway - Professions Robot and want try run it on TAB's.

I can open TAB´s with Multilogin extension and after that modified script counts TAB's and run each user on its own TAB.(this works up to five TAB's and after that website starts freezing)

Problem is that Multilogin is separate extension and it dont know when open TAB's and you also need use "TAB redirect" so Multilogin NEW identity opens allways on new TAB, it works for test but too complicated for users...

I tried look premade userscript, but found nothing usefull or I search wrong items.

Any advice is welcome so I can made script working with "one click" (now I need six click´s + 2x external extension).

ps. I tried look how to change cookies with javascript, but it is still too extensive information for me, :(.

woxxom管理员
§
发表于:2015-04-24
编辑于:2015-05-01
  1. As far as I know there's no way for a userscript to communicate effectively between different browser tabs (although you can try a timer-based GMsetValue/GMgetValue combo) if that's what you want.
  2. Userscripts can only use GM_openInTab to create a new tab, and this function doesn't provide a way to specify cookies or anything except the url to open

So to me it looks like the only solution is making a browser extension.

Edit: I forgot about window.postMessage...

§
发表于:2015-04-24
  • As far as I know there's no way for a userscript to communicate effectively between different browser tabs (although you can try a timer-based GM_setValue/GM_getValue combo) if that's what you want.
  • No need communication between TAB´s and GM can be used so same account not run on two TAB´s, that is not problem, but using timer to get/set values must tried if want do some fancy stats.

  • Userscripts can only use GM_openInTab to create a new tab, and this function doesn't provide a way to specify cookies or anything except the url to open
  • So to me it looks like the only solution is making a browser extension.

    I was afraid that this is complicated... specify cookies per opened TAB and made them "invidual", well I need look that info.

    .... maybe I found some script what can run Multilogin/TAB redirect combo or something.

    Cheers!!! and big THX for information.

    woxxom管理员
    §
    发表于:2015-05-01

    You can try this:

    1. might not work but worth a try:
      var saveCurrentCookies = document.cookies; // or use some js library for that
      document.cookie = "username=User2; expires=......."
      document.cookie = "username=SomeCookie; expires=......."
      GM_openInTab(location.href);
      // restore the changed cookies from saveCurrentCookies
    
    1. should work but the page might flicker on reload:
      1. add @run-at document-start to the meta, you'll also probably have to wrap some code in "DOMContentLoaded" listeners
      2. store the desired cookies GM_setValue("cookies", JSON.stringify(second_user_cookies)).
        It's also possible to use inter-document communication via window.postMessage but it's asynchronous, so a bigger part of the page will be loaded and the flicker will be more obvious.
      3. GM_openInTab to open a tab, your script will be executed at the start:
      4. get the cookies from GM_getValue("cookies")
      5. if it's not empty then enumerate it and set each cookie
      6. refresh the page location.reload(), the new cookies should be used.
    §
    发表于:2015-05-01

    You can try this:

    1. might not work but worth a try:

      var saveCurrentCookies = document.cookies; // or use some js library for that
      document.cookie = "username=User2; expires=......."
      document.cookie = "username=SomeCookie; expires=......."
      GM_openInTab(location.href);
      // restore the changed cookies from saveCurrentCookies
      
    2. should work but the page might flicker on reload:

      1. add @run-at document-start to the meta, you'll also probably have to wrap some code in "DOMContentLoaded" listeners
      2. store the desired cookies GM_setValue("cookies", JSON.stringify(second_user_cookies)).
        It's also possible to use inter-document communication via window.postMessage but it's asynchronous, so a bigger part of the page will be loaded and the flicker will be more obvious.
      3. GM_openInTab to open a tab, your script will be executed at the start:
      4. get the cookies from GM_getValue("cookies")
      5. if it's not empty then enumerate it and set each cookie
      6. refresh the page location.reload(), the new cookies should be used.

    Well, need look it.

    I partially gave up, and look other stuff to add/learn, but need return to look this.

    发表回复

    登录以发表回复。